Skip to content

Refactor/general cleanup#10

Merged
devoreofox merged 11 commits into
mainfrom
refactor/generalCleanup
May 29, 2026
Merged

Refactor/general cleanup#10
devoreofox merged 11 commits into
mainfrom
refactor/generalCleanup

Conversation

@devoreofox
Copy link
Copy Markdown
Owner

Refactor & Cleanup

This PR covers a broad pass of cleanup, bug fixes, and architectural improvements across the plugin.

Removed dead code

EditWindow was no longer wired up anywhere and has been removed entirely.

Fixed a closure capture bug in CommandHandler

The 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 CancellationToken parameter, switched to IReadOnlyList<T>, and removed the unnecessary delay after the final command.

Fixed alias validation

IsValid was splitting on | without trimming whitespace or ignoring empty entries, meaning " " or "mew| " could slip through as valid. Now uses TrimEntries | 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 proper UniqueId

Folders, aliases, and commands all now generate a unique ID via Interlocked.Increment in 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 Blacklist to HashSet<string> with OrdinalIgnoreCase

Previously 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 by Framework.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 CommandDelay clamping

The 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 SelectPanelFooter from AliasSelectPanel

The 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 MainWindow selection to use an event

SelectedAlias was a mutable internal property accessed directly by child panels. It's now driven by a SelectionChanged event, 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), added StringSplitOptions.TrimEntries in the multiline command parser, fixed Log.Error calls 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.

@devoreofox devoreofox merged commit cdac1d4 into main May 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant