InvalidStateError when disabling default key binding


#1

Based on this thread (Disable default keybindings), I have disabled some of the default key bindings, e.g. for the cmd-< shortcut (cycle between windows in OS X).

'.workspace .editor:not(.mini)':
  'cmd-<': ''

This has worked fine so far.

Now starting with v0.120.0, whenever I press this key combination, the error console pops up and shows the following message:

Uncaught InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable. 

/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:400

This is reproducable with other key combindations as well, e.g.

'.editor':
  'cmd-l': ''

Pressing cmd-l now triggers that error as well.

I’m pretty sure this was working with v0.119.0 without any errors.


Disable default keybindings
#2

Rather than using an empty string, unset! is the correct way of disabling a key combination.


#3

I was able to reproduce; something changed in the keymap package. Haven’t bothered checking the specifics, but it’s related to the command event not being initialized properly.

All this being said, I just tested replacing the empty string with a null value and that seems to work as expected. Give it a try.


Edit: or just do as @leedohm suggests :smile:


#4

Excellent - thanks! This worked:

'.workspace .editor:not(.mini), .workspace':
  'cmd-<': 'unset!'

I’ll add this to the other thread as well.


#5

Maybe a reference to using unset! or native! should be added to the auto-generated keymap file in the comment blurb at the top of the file.

Or even better a reference to this help page, since it explains these options in more detail.