vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Auto-quoting of context keys prevents removal of keybindings via UI

Open pfitzseb opened this issue 3 years ago • 0 comments

Does this issue occur when all extensions are disabled?: Probably, but hard to reproduce

  • VS Code Version: 1.70.0 and insiders
  • OS Version: Linux x64 5.18.16-1-MANJARO

Steps to Reproduce:

  1. Install an extension that contributes a keybinding with a when clause containing an foo in extension.bar check (e.g. the Julia extension).
  2. Go to the Keyboard Shortcuts UI via workbench.action.openGlobalKeybindings
  3. Right click -> remove the keybinding.
  4. VS Code tries to remove the keybinding by inserting a new one into the User/keybindings.json, where the command is prefixed with a minus and, crucially, all complex context keys are quoted:
[
    {
        "key": "ctrl+enter",
        "command": "-extension.my-command",
        "when": "foo in 'extension.bar'"
    }
]
  1. This doesn't actually remove the keybinding from the UI or prevent VS Code from resolving it.
  2. Remove the single quotes around 'extension.bar'
  3. The keybinding is properly removed from the UI and cannot be used anymore, as expected.

As far as I can tell, this behaviour is specific to in clauses; it's also hard to repro this without an extension because user-supplied keybindings are just removed outright from keybindings.json instead of adding an additional negated entry.

Peek 2022-08-10 11-53

pfitzseb avatar Aug 10 '22 09:08 pfitzseb