Repository: vscode
Issue: Keyboard shortcuts "get stuck" with invalid "when expressions"
Labels: bug,keybindings-editor

Type: <b>Bug</b>

I was messing around with some keyboard shortcuts for an extension and came across this bug.

Let's say you modify a "when expression" like so:

<img width="1251" alt="Screen Shot 2023-09-19 at 14 09 43" src="https://github.com/microsoft/vscode/assets/4754387/441c6f22-dcbe-4016-be97-64b7a505a51e">

Apparently this makes it an invalid expression, but the fact that `!!` isn't supported isn't the issue here. Whenever you make an invalid expression, regardless of how, you end up with this:

<img width="1254" alt="Screen Shot 2023-09-19 at 14 10 03" src="https://github.com/microsoft/vscode/assets/4754387/7fd479bc-e405-47bf-ae9c-5475f8ee7497">

Just... blank. "Okay," I thought, "well I'll just change it back!"

<img width="1254" alt="Screen Shot 2023-09-19 at 14 10 31" src="https://github.com/microsoft/vscode/assets/4754387/fe4c40a5-2f70-4d6c-85b2-f65fbc3170ad">

Nope! It's empty now. And trying to change it or reset it just makes what appears to be a duplicate binding:

<img width="1252" alt="Screen Shot 2023-09-19 at 14 10 45" src="https://github.com/microsoft/vscode/assets/4754387/106dfd16-a13c-4959-91a1-1195640d2e5c">

<img width="1260" alt="Screen Shot 2023-09-19 at 14 10 51" src="https://github.com/microsoft/vscode/assets/4754387/39f21994-a390-42d5-969e-77f274185a3a">

"Uh... that's weird. Okay, I'll just try to delete the old one..."

<img width="1256" alt="Screen Shot 2023-09-19 at 14 10 57" src="https://github.com/microsoft/vscode/assets/4754387/4c6c8286-279c-4fec-831c-6dff71485945">

That didn't work either. It's like the binding is completely frozen -- I can't change anything about it or remove it.

After spending some time digging, I realized that VSCode has a `keybindings.json` file, where I found the offending binding and removed it.

<img width="364" alt="Screen Shot 2023-09-19 at 14 11 09" src="https://github.com/microsoft/vscode/assets/4754387/bb8aaa86-bbf5-479e-a66d-66815b9539ce">

After a reload, FINALLY, everything is as it should be again:

<img width="1248" alt="Screen Shot 2023-09-19 at 14 11 20" src="https://github.com/microsoft/vscode/assets/4754387/2c1080eb-d368-4bc3-9e04-2abbbb32e83f">

True story! Happened to me just now. Kind of annoying. (Actually, *really* annoying if you don't know where to find `keybindings.json` -- I had found this issue with an extension binding that messed up my backspace key, meaning I could not delete text *anywhere* in *any text field* in the editor until I figured this out. 😓)

I'm not sure what the solution is here or how things work internally that would make this behavior happen... I just know this is probably not how "when expressions" should be dealt with.

VS Code version: Code 1.82.1 (Universal) (6509174151d557a81c9d0b5f8a5a1e9274db5585, 2023-09-08T08:49:32.930Z)
OS version: Darwin arm64 21.6.0
Modes:

<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|Apple M1 Max (10 x 24)|
|GPU Status|2d_canvas: enabled<br>canvas_oop_rasterization: enabled_on<br>direct_rendering_display_compositor: disabled_off_ok<br>gpu_compositing: enabled<br>multiple_raster_threads: enabled_on<br>opengl: enabled_on<br>rasterization: enabled<br>raw_draw: disabled_off_ok<br>video_decode: enabled<br>video_encode: enabled<br>vulkan: disabled_off<br>webgl: enabled<br>webgl2: enabled<br>webgpu: enabled|
|Load (avg)|4, 5, 5|
|Memory (System)|32.00GB (0.06GB free)|
|Process Argv|--crash-reporter-id 3127eb55-8d69-40f1-bfb7-076e12c7fa7d|
|Screen Reader|no|
|VM|0%|
</details><details><summary>Extensions (33)</summary>

Extension|Author (truncated)|Version
---|---|---
markdown-mermaid|bie|1.19.0
markdown-preview-github-styles|bie|2.0.2
dart-code|Dar|3.72.2
flutter|Dar|3.72.0
vscode-eslint|dba|2.4.2
vscode-quick-select|dba|0.2.9
gitlens|eam|14.3.0
code-coverage|mar|1.11.0
Kotlin|mat|1.7.1
isort|ms-|2023.10.1
python|ms-|2023.16.0
vscode-pylance|ms-|2023.9.10
cpptools|ms-|1.17.5
hexeditor|ms-|1.9.12
live-server|ms-|0.4.9
vsliveshare|ms-|1.0.5883
vscode-react-native|msj|1.11.2
java|red|1.22.1
multi-command|ryu|1.6.0
memento-inputs|spa|1.0.0
electris|und|0.0.1
pdf|tom|1.2.2
cmake|twx|0.0.17
intellicode-api-usage-examples|Vis|0.2.8
vscodeintellicode|Vis|1.2.30
vscode-gradle|vsc|3.12.7
vscode-java-debug|vsc|0.54.0
vscode-java-dependency|vsc|0.23.1
vscode-java-pack|vsc|0.25.14
vscode-java-test|vsc|0.39.1
vscode-maven|vsc|0.42.0
markdown-pdf|yza|1.5.0
markdown-all-in-one|yzh|3.5.1

(1 theme extensions excluded)

</details><details>
<summary>A/B Experiments</summary>

```
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627:30244334
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscoreces:30445986
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30410667
vsclangdf:30486550
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
2e4cg342:30602488
89544117:30613380
showlangstatbar:30737416
03d35959:30757346
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
pythonnosmt12:30797651
pythonidxpt:30805730
pythonnoceb:30805159
copilotsettingc:30839828
asynctok:30821568
dsvsc013:30795093
dsvsc014:30804076
diffeditorv2:30821572
dsvsc015:30829745

```

</details>

<!-- generated by issue reporter -->