Fix remapped shortcuts not getting activated in succession #4712
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.
Summary of the Pull Request
This PR fixes a scenario where a user could remap Alt+A->Ctrl+A, Alt+V->Ctrl+V and if you press Alt+A, release A and press V, Ctrl+V was not getting invoked. This was happening because when we fixed Alt+Tab style shortcuts in #3965, we changed the behavior such that we release the remapped modifier only after a key apart from the invoked shortcut's keys are pressed. When this would happen, we would reset the keyboard state to whichever keys should be physically pressed at that time, however we were sending all the keys including the latest pressed key (V in the example), with the
KEYBOARDMANAGER_SHORTCUT_FLAG
, because of which when the system received Alt+V it would not remap it to Ctrl+V. The fix involves removing the flag for that particular key event. We still keep the shortcut flag for all the key events before that so that we don't reinvoke the initial shortcut and cause an infinite recursion.Comments have been updated to clarify the flag usage and two test cases have been added to capture the scenario.
PR Checklist
Validation Steps Performed
Added test cases and manually validated with the repro steps in the issue