Skip to content

Keyboard Shortcuts: Change When Expression might actually remove keybinding in Insiders #141638

@IllusionMH

Description

@IllusionMH

Issue Type: Bug

I think this changed somwhere in January (I don't think I've noticed it in late December).

Steps to repoduce:

  1. Open Keyboard Shortcuts editor
  2. Find shortcut without when expression (e.g. workbench.action.closeActiveEditor)
  3. Right click and select "Change When Expression"
  4. Add when expression (e.g. editorTextFocus) and save it
  5. Shortcut is removed from filtered results and doesn't work when cursor is in editor.

Root cause is that Change When Expression creates 2 records in keybindings.json:

{
    "key": "ctrl+w",
    "command": "workbench.action.closeActiveEditor",
    "when": "editorTextFocus"
},
{
    "key": "ctrl+w",
    "command": "-workbench.action.closeActiveEditor"
}

and lately "command": "-commandIdЭ without when removes all keybindings without taking when into account.
Swithing order of these objects restores expected behavior.

Looks like this doesn't happen if keybinding already had when expression. For example next change displayed in list as expected

{
    "key": "escape",
    "command": "editor.debug.action.closeExceptionWidget",
    "when": "exceptionWidgetVisible && editorTextFocus"
},
{
    "key": "escape",
    "command": "-editor.debug.action.closeExceptionWidget",
    "when": "exceptionWidgetVisible"
},

VS Code version: Code - Insiders 1.64.0-insider (3dda6ea, 2022-01-27T05:15:00.564Z)
OS version: Windows_NT x64 10.0.19041
Restricted Mode: No

System Info
Item Value
CPUs Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz (12 x 3192)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 31.72GB (20.14GB free)
Process Argv --crash-reporter-id cf52dbde-2c94-45c3-9bf3-45d8b9966b04
Screen Reader no
VM 0%
Extensions: none

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugkeybindingsVS Code keybinding issuesregressionSomething that used to work is now brokenverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions