Both actions happening when I try to replace key binding


#1

I’m having a weird issue trying to replace a key binding. I added an entry to my keymap.cson with the same selector, and now it seems that both actions are happening instead of just the one I added. Specifically I’m trying to remap the backspace key to inline:clear-current from the Ink package.

keymap.cson:

'atom-text-editor.vim-mode-plus:not(.insert-mode)':
  'k': 'vim-mode-plus:move-up-screen'
  'j': 'vim-mode-plus:move-down-screen'
  'backspace': 'inline:clear-current'

And here’s what I see when I use the key binding resolver and press backspace:

The behavior I see is that it runs inline:clear-current but also moves the cursor left. This is on Atom 1.16 on Windows. I would expect my binding to win, so it should show up in green in the keybinding resolver and also be the only action to execute. I’m not really sure if this is a problem with my understanding or a bug.


#2

I believe they’re both firing because the selectors have the same specificity. You could try body atom-text-editor.vim-mode-plus:not(.insert-mode).


#3

prepending body didn’t change the behavior (even after restarting Atom)


#4

What does the Keybinding Resolver look like in that case?


#5

Looks the same, except that my keybinding selector is listed as body atom-text-editor.vim-mode-plus:not(.insert-mode). The vim keybinding still shows up in green above mine.


#6

Okay, so priority isn’t counted. The Flight Manual says, “By default, keymap.cson is loaded when Atom is started. It will always be loaded last, giving you the chance to override bindings that are defined by Atom’s core keymaps or third-party packages.” So if Atom gives priority to the most recently loaded bindings, then I hypothesize that vim-mode-plus could be interfering with the system in some fashion by telling Atom to load its keymaps later. I’m not sure if that’s possible, but if it is, then what you see would be the outcome.


#7

Interesting, thanks for the feedback. I’ll file an issue on vim-mode-plus and see if they’re doing anything sneaky.