Refactor/general cleanup#10
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor & Cleanup
This PR covers a broad pass of cleanup, bug fixes, and architectural improvements across the plugin.
Removed dead code
EditWindowwas no longer wired up anywhere and has been removed entirely.Fixed a closure capture bug in
CommandHandlerThe loop variable was being captured by reference in the async lambda, meaning all scheduled commands would execute the last command in the list. Each command is now captured correctly before the lambda. Also added a
CancellationTokenparameter, switched toIReadOnlyList<T>, and removed the unnecessary delay after the final command.Fixed alias validation
IsValidwas splitting on|without trimming whitespace or ignoring empty entries, meaning" "or"mew| "could slip through as valid. Now usesTrimEntries | RemoveEmptyEntries.Fixed filter not checking display names
The filter in the alias select panel was only matching against
Name, so aliases with a display name set would be invisible to search unless you typed their raw command name.Replaced
GetHashCode()folder identity with a properUniqueIdFolders, aliases, and commands all now generate a unique ID via
Interlocked.Incrementin their constructor rather than relying on hash codes or draw-loop assignment. Added[JsonIgnore]alongside[NonSerialized]so IDs are never persisted. This also fixed a bug where importing an alias from clipboard would collide IDs with the original, making one of them unselectable.Switched
BlacklisttoHashSet<string>withOrdinalIgnoreCasePreviously a
string[], which meant O(n) contains checks and a manual comparer argument on every call. Now O(1) with the comparer baked in at construction.Debounced saves
Rapid text input (alias names, commands) was triggering a full config save on every keystroke. Added
MarkDirty()/TrySave(debounce)with a 500ms debounce window driven byFramework.Update. Explicit actions like toggling enabled, deleting, or creating still save immediately. The dirty state is intentionally not flushed on dispose -- if a bad alias crashes the game, the debounce window means the broken config likely hasn't been saved yet.Added
CommandDelayclampingThe setter now clamps to
[0, 1000]so it's impossible to persist an out-of-range value regardless of how the config file gets edited.Extracted
SelectPanelFooterfromAliasSelectPanelThe footer button bar (new alias, import, clone, new folder, delete) has been moved to its own class. It communicates back via callbacks rather than touching panel state directly, which also eliminated the last remaining direct state mutations in the context menus -- those now go through
BeginRenameAlias/BeginRenameFolder.Refactored
MainWindowselection to use an eventSelectedAliaswas a mutable internal property accessed directly by child panels. It's now driven by aSelectionChangedevent, and panels subscribe rather than poke shared state.Improved error handling on clipboard import
Import failures now log the exception properly and surface a toast notification to the user rather than silently swallowing the error.
Miscellaneous
Fixed several typos (
occured,Seperate), addedStringSplitOptions.TrimEntriesin the multiline command parser, fixedLog.Errorcalls to include the exception object, and added a conditional tooltip on the alias enabled checkbox that reads "Enable this alias" or "Disable this alias" depending on current state.