microsoft / vscode

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

Command mapped to "Space" is getting invoked despite (presumably) correct `when` clause #111848

Closed macintacos closed 3 years ago

macintacos commented 3 years ago

Issue Type: Bug

I previously opened this issue here, however it was determined that because the extension is using a webview, the when clause isn't properly met, which is an issue that VScode would have to handle in order to make sure that it has consistent enforcement across any extension with webviews:

I have the following keybinding:

  {
    "key": "space",
    "command": "vspacecode.space",
    "when": "!whichkeyActive && !inputFocus && !textInputFocus"
  },

This works perfectly fine pretty much everywhere I've tried, except in the comment field in the sidebar when I go to approve/request changes on a PR. When I hit "Space", the above command gets invoked, even though I believe that technically that text field should have focus (and thus should be ignored based on the above when clause).

Am I missing something? Is there a "proper" when clause so that I can leave "Space" mapped to that command? Otherwise I guess I'll still need to use the web interface (which is what I'm trying to void by using this extension in the first place 🙂 )

Any pointers would be much appareciated. Thanks!

  • Extension version: 0.21.0
  • VSCode Version: 1.51.0
  • OS: macOS 10.15.7

Steps to Reproduce:

  1. Set up the above keybinding with the VSpaceCode extension installed > and properly configured.
  2. Try typing in a PR's comment field and hit "Space"
  3. VSpaceCode is invoked, despite the when clause seemingly not being true.

IMO, if I'm in a text/input field (regardless of whether or not I'm in a web view or not - as a user I can't be expected to know what's a web view and what's native UI elements) the above when clause should work. Opening this as a bug to reflect that.

Any pointers about how to make this work would be very much appreciated. Thanks!

VS Code version: Code 1.51.1 (e5a624b788d92b8d34d1392e4c4d9789406efe8f, 2020-11-11T01:11:34.018Z) OS version: Darwin x64 19.6.0

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz (16 x 2300)| |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: enabled
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled| |Load (avg)|3, 2, 3| |Memory (System)|32.00GB (0.47GB free)| |Process Argv|--crash-reporter-id c6914155-166f-4175-88b3-886232e620cd| |Screen Reader|no| |VM|0%|
Extensions (155) Extension|Author (truncated)|Version ---|---|--- better-comments|aar|2.1.0 html-snippets|abu|0.2.1 scss-lint|ada|0.1.10 vscode-javascript-snippet-pack|aka|0.1.6 Bookmarks|ale|12.0.0 project-manager|ale|12.0.1 vscode-bazel|Baz|0.4.0 search-crates-io|bel|1.2.1 color-info|bie|0.5.1 github-markdown-preview|bie|0.0.2 markdown-emoji|bie|0.0.9 markdown-preview-github-styles|bie|0.1.6 vscode-fish|bma|1.0.20 file-browser|bod|0.2.10 htmltagwrap|bra|0.0.7 vscode-tailwindcss|bra|0.5.4 language-hugo-vscode|bud|1.2.0 better-toml|bun|0.3.2 npm-intellisense|chr|1.3.1 path-intellisense|chr|2.3.0 gotoanything|Cma|0.4.1 gitignore|cod|0.6.0 bracket-pair-colorizer-2|Coe|0.2.0 disableligatures|Coe|0.0.10 compulim-vscode-closetag|Com|1.2.0 vscode-svgviewer|css|2.0.0 postcss|css|1.0.9 transformer|dak|1.9.0 vscode-markdownlint|Dav|0.37.2 vscode-eslint|dba|2.1.13 vscode-dash|dee|2.4.0 confluence-markup|den|0.1.8 vscode-deno|den|2.3.3 xml|Dot|2.5.1 viml|dun|0.1.7 gitlens|eam|11.0.6 vscode-html-css|ecm|0.2.3 EditorConfig|Edi|0.16.3 vscode-npm-script|eg2|0.3.13 LogFileHighlighter|emi|2.10.0 vscode-great-icons|emm|2.1.62 vsc-material-theme-icons|equ|1.2.0 prettier-vscode|esb|5.8.0 vscode-go-test-adapter|eth|0.1.4 copy-relative-path-and-line-numbers|ezf|0.3.1 vscode-git-history|fab|2.0.5 vscode-open-in-github|fab|1.2.3 file-icons|fil|1.0.27 vscode-firefox-debug|fir|2.9.1 vscode-npm|fkn|3.3.0 auto-close-tag|for|0.5.9 code-runner|for|0.11.1 shell-format|fox|7.0.1 sort-json-array|fvc|2.0.3 nightswitch|gha|1.1.0 vscode-sublime-merge|gio|1.3.0 vscode-pull-request-github|Git|0.21.2 go|gol|0.19.0 gc-excelviewer|Gra|3.0.40 todo-tree|Gru|0.0.188 terraform|has|2.3.0 vscode-test-explorer|hbe|2.19.3 npm-dependency-links|her|1.2.0 headwind|hey|1.7.0 vscode-settings-cycler|hoo|1.0.1 output-colorizer|IBM|0.1.2 smarty|imp|0.3.0 customize-ui|ioc|0.1.49 monkey-patch|ioc|0.1.11 path-autocomplete|ion|1.15.0 fuzzy-search|jac|0.0.3 RelativePath|jak|1.4.0 TypeScriptImport|kev|1.17.0 json2csv|kha|0.0.1 vscode-gutter-preview|kis|0.26.2 vscode-format-context-menu|lac|1.0.4 rpm-spec|Lau|0.3.1 vscode-simple-icons|Lau|1.13.5 vscode-fix-checksums|leh|1.1.0 node-module-intellisense|lei|1.5.0 expand-region|let|0.1.4 bash-ide-vscode|mad|1.11.0 rust-analyzer|mat|0.2.400 Lisp|mat|0.1.11 markdown-shortcuts|mdi|0.12.0 rainbow-csv|mec|1.8.0 HTMLHint|mka|0.10.0 mongodb-vscode|mon|0.3.0 vscode-less|mrm|0.6.3 vscode-docker|ms-|1.8.1 vscode-kubernetes-tools|ms-|1.2.1 python|ms-|2020.11.371526539 vscode-pylance|ms-|2020.12.0 jupyter|ms-|2020.11.392013122 cpptools|ms-|1.1.2 vscode-typescript-tslint-plugin|ms-|1.2.3 debugger-for-chrome|msj|4.12.11 vscode-paste-image|mus|1.0.4 color-highlight|nau|2.3.0 autodocstring|njp|0.5.4 indent-rainbow|ode|7.4.0 vscode-nunjucks-formatter|oki|0.1.3 fix-json|oli|0.1.2 markdown-checkbox|PKi|1.7.0 material-icon-theme|PKi|4.4.0 vscode-css-peek|pra|4.0.2 text-power-tools|qcz|1.18.0 ruby|reb|0.27.0 vscode-xml|red|0.14.0 vscode-yaml|red|0.13.0 explorer-exclude-vscode-extension|Red|1.2.0 shellman|Rem|4.7.0 vscode-sort-json|ric|1.18.1 synthwave-vscode|Rob|0.1.8 bash-debug|rog|0.3.9 zsh-debug|rog|0.1.3 nunjucks|ron|0.3.0 codeui|rya|0.3.0 partial-diff|ryu|1.4.1 multi-command|ryu|1.4.0 vscode-javascript-booster|sbu|14.0.1 crates|ser|0.5.3 code-settings-sync|Sha|3.4.3 vscode-brewfile|sha|1.0.0 trailing-spaces|sha|0.3.1 mdx|sil|0.1.0 vscode-fileutils|sle|3.4.2 snipsnap-vscode|sni|1.1.0 control-snippets|svi|1.9.1 vscode-markdown-paste-image|tel|0.12.3 shellcheck|tim|0.12.1 alex-linter|tla|0.6.5 write-good-linter|tra|0.1.4 go-to-method|tri|0.2.0 sort-lines|Tyr|1.9.0 errorlens|use|3.2.4 remove-empty-lines|use|0.0.6 vscode-lldb|vad|1.6.0 vscode-icons|vsc|11.0.0 vim|vsc|1.17.2 vspacecode|VSp|0.8.4 whichkey|VSp|0.8.2 file-icons-mac|way|1.0.1 vscode-icons-mac|way|7.25.3 vscode-todo-highlight|way|1.0.4 twig|wha|1.0.2 vscode-ruby|win|0.27.0 change-case|wma|1.0.0 better-align|wwm|1.1.6 clang-format|xav|1.9.0 vs-code-wiki|Yun|0.5.0 markdown-all-in-one|yzh|3.4.0 material-theme|zhu|3.9.11 html-css-class-completion|Zig|1.19.0 vscode-open-in-github|ziy|1.3.6 (13 theme extensions excluded)
mjbvz commented 3 years ago

Closing this since we can't reliably track where a user is focused inside of a webview and I don't see the payoff of trying to fix this as being worth the engineering cost

As discussed upstream, you can try using when clauses that target specific scenarios instead of when clauses that try explicating specific ones

alexwforsythe commented 1 year ago

This worked for me:

  {
    "key": "space",
    "command": "vspacecode.space",
-    "when": "!whichkeyActive && !inputFocus && !textInputFocus"
+    "when": "!whichkeyActive && !inputFocus && !textInputFocus && !github:createPullRequestWebview.active"
  },