microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.38k stars 28.62k forks source link

Can't type in Cmd+` in Keyboard Shortcut UI #146815

Open aleksandr-vin opened 2 years ago

aleksandr-vin commented 2 years ago

Issue Type: Bug

Open Keyboard Shortcuts tab. Click to edit any. In the input try holding Cmd and press '`' key. It is not appearing in the input field.

Workaround: enter any non-existing combo (like shift-), then open Keyboard Shortcuts JSON and find that entry, replace string to "cmd+".

VS Code version: Code 1.65.2 (c722ca6c7eed3d7987c0d5c3df5c45f6b15e77d1, 2022-03-10T14:42:05.236Z) OS version: Darwin arm64 21.1.0 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|Apple M1 Pro (8 x 24)| |GPU Status|2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled| |Load (avg)|3, 3, 3| |Memory (System)|32.00GB (0.08GB free)| |Process Argv|--crash-reporter-id 7c274816-b412-4d9f-ad5b-d50b8a8f63bf| |Screen Reader|no| |VM|0%|
Extensions (26) Extension|Author (truncated)|Version ---|---|--- jest-snippets|and|1.8.0 csharpier-vscode|csh|1.2.1 xml|Dot|2.5.1 es7-react-js-snippets|dsz|4.4.3 gitlens|eam|12.0.5 prettier-vscode|esb|9.5.0 unity-code-snippets|kle|1.3.0 vscode-docker|ms-|1.21.0 csharp|ms-|1.24.3 vscode-kubernetes-tools|ms-|1.3.7 python|ms-|2022.4.0 vscode-pylance|ms-|2022.3.4 jupyter|ms-|2022.2.1030672458 jupyter-keymap|ms-|1.0.0 jupyter-renderers|ms-|1.0.6 remote-containers|ms-|0.231.3 vsliveshare|ms-|1.0.5449 vscode-yaml|red|1.6.0 html-to-jsx|ria|0.0.1 scala|sca|0.5.5 metals|sca|1.13.0 prettier-vscode|Sim|2.0.7 paste-clean-diff|siv|1.1.0 unity-debug|Uni|3.0.2 errorlens|use|3.4.2 propertylist|zho|0.0.2
IllusionMH commented 2 years ago

/needsMoreInfo

Please follow steps from https://github.com/microsoft/vscode/wiki/Keybinding-Issues to check if VS Code receives this shortcut

aleksandr-vin commented 2 years ago

/needsMoreInfo

Please follow steps from https://github.com/microsoft/vscode/wiki/Keybinding-Issues to check if VS Code receives this shortcut

Before I'll get lost in that manual page, I'd like to testify: the VS Code receives this shortcut as I specified in the workaround – I'm using this shortcut 'cmd+`' after I configured it via workaround :)

Please say if I do need to go through that manual to perform other checks, @IllusionMH

alexdima commented 2 years ago

@aleksandr-vin cmd + ` is typically predefined on macos as a command to switch windows of the same application. To be able to use it in applications, you would need to remove it from the OS settings:

image

Have you removed it from there?

aleksandr-vin commented 2 years ago

@alexdima thanks for that tip. I've checked: I don't have it removed from there and it works both in VS Code and in macOs.

So what I experience now:

  1. When I have it configured in JSON, then it does work in VS Code in both versions: when removed (disabled) from System Preferences > Shortcuts > Keyboard and when enabled. By work I mean VS Code opens (and closes on next hit) Terminal when I hit `cmd + `` in VS Code.
  2. When I have it configured in JSON, then I can't enter it in Keyboard Shortcuts (not JSON) in VS Code: it opens Terminal instead of putting the keystrokes in the input field. That behaviour is not affected by enabling/disabling it in System Preferences.
  3. When I have it not configured in JSON (when I set different combo for Open Terminal command), then I can't enter it in Keyboard Shortcuts (not JSON) in VS Code: it just does register it only like cmd is pressed. That behavior is not affected by enabling/disabling it in System Preferences.
VSCodeTriageBot commented 2 years ago

Hey @alexdima, this issue might need further attention.

@aleksandr-vin, you can help us out by closing this issue if the problem no longer exists, or adding more information.

alexdima commented 2 years ago

OK, I think I have some idea towards what might be going on. The command View: Toggle Terminal (workbench.action.terminal.toggleTerminal) is rendered in the native macOS menu under View > Terminal. Our menus respect the keybindings.json when rendering a keybinding next to the menu entries. So, when configuring:

{ "key": "cmd+`", "command": "workbench.action.terminal.toggleTerminal"}

This keybinding will be reflected in the native macOS menus (under View > Terminal):

image

As soon as a keybinding is displayed in the native macOS menu, it will be dispatched by the OS, and not by us. So, the OS now knows that we have a command bound to cmd + ` and when pressing cmd + ` the OS will behave as if the menu was clicked (on our side we just get to learn that the menu action was invoked). So we still don't receive the keybinding, the OS invokes the menu action for us. That is why the keyboard shortcut UI cannot log or capture the keybinding.

To sum up:

I don't really know what would be the best way to improve things here. @deepak1556 Are you aware if there are native macOS APIs around the way menus are created that would give us some sort of setting to control this behavior?

VSCodeTriageBot commented 2 years ago

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

VSCodeTriageBot commented 2 years ago

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!