microsoft / vscode

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

Keyboard shortcut to editor.action.insertSnippet does not execute action #87485

Closed tillig closed 4 years ago

tillig commented 4 years ago

Issue Type: Bug

  1. Go to Preferences -> Keyboard Shortcuts
  2. Search for editor.action.insertSnippet. Usually this is Ctrl+Alt+J on Windows or Option+Command+J on Mac.
  3. Go to a file and execute that key binding.

I expect to see the list of available snippets show up at the top, as though I had selected "Insert Snippet" from the command palette.

Instead, nothing happens, like the keybinding literally doesn't do anything. I see no log messages in any window. I've tested this on both Mac and Windows.

VS Code version: Code 1.41.1 (26076a4de974ead31f97692a0d32f90d735645c0, 2019-12-18T14:57:51.166Z) OS version: Darwin x64 19.2.0

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz (8 x 2700)| |GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off
surface_control: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|2, 2, 2| |Memory (System)|16.00GB (1.18GB free)| |Process Argv|| |Screen Reader|no| |VM|0%|
Extensions (57) Extension|Author (truncated)|Version ---|---|--- ng-template|Ang|0.900.3 color-info|bie|0.5.1 npm-intellisense|chr|1.3.0 path-intellisense|chr|1.4.2 vscode-markdownlint|Dav|0.33.0 vscode-eslint|dba|2.0.11 xml|Dot|2.5.0 gitlens|eam|10.2.0 EditorConfig|Edi|0.14.4 vscode-npm-script|eg2|0.3.10 auto-close-tag|for|0.5.6 auto-rename-tag|for|0.1.1 code-runner|for|0.9.15 dotnet-test-explorer|for|0.7.1 todo-tree|Gru|0.0.162 beautify|Hoo|1.5.0 output-colorizer|IBM|0.1.2 restructuredtext|lex|116.0.0 terraform|mau|1.4.0 dotenv|mik|1.0.1 ecdc|mit|1.3.0 nc-gcode|ML|0.13.0 vscode-docker|ms-|0.9.0 vscode-aks-tools|ms-|0.0.4 vscode-kubernetes-tools|ms-|1.0.9 mssql|ms-|1.8.0 python|ms-|2019.11.50794 remote-wsl|ms-|0.41.6 azure-account|ms-|0.8.7 cpptools|ms-|0.26.2 csharp|ms-|1.21.9 Go|ms-|0.11.9 powershell|ms-|2019.12.0 sublime-keybindings|ms-|4.0.6 vscode-typescript-tslint-plugin|ms-|1.2.3 azurerm-vscode-tools|msa|0.8.3 debugger-for-chrome|msj|4.12.3 polacode|pnp|0.3.4 java|red|0.54.2 vscode-yaml|red|0.6.1 code-settings-sync|Sha|3.4.3 markdown-preview-enhanced|shd|0.5.0 guides|spy|0.9.3 rewrap|stk|1.9.1 msbuild-project-tools|tin|0.3.2 vscode-json-stable-stringify|Tra|1.1.0 sort-lines|Tyr|1.9.0 vscodeintellicode|Vis|1.2.2 vscode-arduino|vsc|0.2.28 vscode-java-debug|vsc|0.23.0 vscode-java-dependency|vsc|0.6.0 vscode-java-pack|vsc|0.8.1 vscode-java-test|vsc|0.22.0 vscode-maven|vsc|0.20.1 vscode-icons|vsc|9.6.0 material-theme|zhu|3.2.1 html-css-class-completion|Zig|1.19.0
kieferrm commented 4 years ago

The command does not have a keyboard shortcut by default.

tillig commented 4 years ago

Maybe it shouldn't, but I didn't add it and it shows as one of the defaults. I did try changing it to other key bindings and it never works.

vscodebot[bot] commented 4 years ago

Thanks for creating this issue! We figured it's missing some basic information or in some other way doesn't follow our issue reporting guidelines. Please take the time to review these and update the issue.

Happy Coding!

tillig commented 4 years ago

I gather the missing information is "what happens when no extensions are enabled." That's... a great question.

After doing some enable/disable checking... it turns out there is an interesting conflict between:

After disabling and re-enabling all the extensions, the one that was editor.action.insertSnippet and just editorTextFocus disappeared. I'm not sure what extension had added it.

The winning combination for me that appears to have fixed it:

[
    {
        "key": "ctrl+alt+j",
        "command": "-code-runner.runByLanguage"
    },
    {
        "key": "ctrl+alt+j",
        "command": "editor.action.insertSnippet",
        "when": "editorTextFocus"
    },
    {
        "key": "ctrl+alt+j",
        "command": "-editor.action.insertSnippet",
        "when": "editorTextFocus && editorLangId == 'powershell'"
    }
]

Basically - remove the bindings from the other two extensions and add my own.

As an aside, the documentation that says you can get to your keybindings.json file by going to the preferences menu is wrong - There doesn't seem to be any option anymore to open the settings.json or keybindings.json directly. You have to find the files manually.

Thanks for your patience on this!