This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
Fix so AltGraph is resolved as a modifier and not as a key #231
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.
Description of the Change
In Atom 1.24 pressing AltGraph on Windows sends these two events:
This changed in Atom 1.25 due to the Electron upgrade so the
Alt
key is nowAltGraph
:This caused atom-keymap to resolve a single AltGraph as
ctrl-alt-altgraph
because we receive one event forControl
which hasaltKey
andctrlKey
true and one event forAltGraph
(which also hasaltKey
andctrlKey
true). SinceAltGraph
is not a modifier Atom resolved this as a key in the following code:atom-keymap/src/helpers.coffee
Lines 254 to 256 in 802745d
This also causes issues with partial matching because the AltGraph key cancels pending keystrokes. So a keybinding like:
Would resolve to
g altgraph
and then$
never matching the entire keybinding.This Pull Request adds AltGraph as a modifier and a special case for when the
key
isaltgraph
to correctly resolve when AltGraph is included in the keystroke.Alternate Designs
I don't really like the design in this PR but I still went with it! Maybe we can just change the
key
toalt
when it isAltGraph
usingNON_CHARACTER_KEY_NAMES_BY_KEYBOARD_EVENT_KEY
atom-keymap/src/helpers.coffee
Lines 11 to 18 in 802745d
In the interest of time I did not investigate any alternative designs so I could get this PR up and at least document the issue.
There are quite a few issues about AltGraph misbehaving on Linux even before the Electron upgrade so there might be another bug on Linux. If Linux has a similar issue for another reason than this there might be an alternative design that also fixes these issues.
atom/atom#16242
t9md/atom-vim-mode-plus#661
#126
t9md/atom-vim-mode-plus#1031
Happy to hear any ideas for alternatives!
Benefits
Fixes a regression from the Electron upgrade.
Possible Drawbacks
Verification Process
I added the following keymap:
Since $ is typed using AltGraph+4 on a Swedish layout this command includes the AltGraph character. The expected result is that we can match the keybinding even when AltGraph is included in the keystroke.
I also tested that the command matches if you press
g ctrl-alt-4
.Applicable Issues
These are in an earlier version of Atom. There might be some other bug on Linux for AltGraph.
atom/atom#16242
t9md/atom-vim-mode-plus#661
#126
t9md/atom-vim-mode-plus#1031