-
Notifications
You must be signed in to change notification settings - Fork 724
Fixes #1962 - Change KeyBindings to allow chaining commands #1966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Needs more tests (hence Draft) but I think that this is what 'command chaining' would look like. I've changed It also means a user could specify no |
I like your solution for this.
No big deal, compiling again solves it.
I think is better to throw an exception if the command is null or was not passed no command at all. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, tidy, work.
public void ClearKeybinding (params Command [] command) | ||
{ | ||
foreach (var kvp in KeyBindings.Where (kvp => kvp.Value == command).ToArray ()) { | ||
foreach (var kvp in KeyBindings.Where (kvp => kvp.Value.SequenceEqual (command))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was just looking again at this code and see that we lost the .ToArray()
. I thought this would cause the old 'Collection modified during enumeration' error but the test passes which is wierd.
I looked into why and it seems maybe the behaviour changed as of .netcore3.1. I will open a quick PR to put it back incase this would break when running on an older runtime.
Ideally, it is not advisable to do it. The GetEnumerator() that is called while iterating to the next item will throw an InvalidOperationException. However, from .netcore 3.1 onwards, this will work when you do a dictionary.Remove() or dictionary.Clear() from inside the loop.
Fixes #1962 - Allow specifying more than 1
Command
to order when usingAddKeyBinding
Pull Request checklist:
CTRL-K-D
to automatically reformat your files before committing.dotnet test
before commit///
style comments)