Microsoft/vscode

`editor.action.selectAll` gets triggered for webview editors, preventing them from overriding the keybinding behavior for ctrl/cmd+a

Open

#236,373 创建于 2024年12月17日

在 GitHub 查看
 (0 评论) (0 反应) (1 负责人)TypeScript (10,221 fork)batch import
bughelp wantedwebview

仓库指标

Star
 (74,848 star)
PR 合并指标
 (平均合并 11小时 43分钟) (30 天内合并 1,000 个 PR)

描述

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version: 1.96.0
  • OS Version: macOS 14.7.2

Steps to Reproduce:

  1. Install Swimm.swimm
  2. Do the whole setup needed for the extension, login, create workspace, add repo.
  3. Open an editor and add a sample Mermaid diagram (/mermaid and select some sample).
  4. Hit Ctrl/Cmd+A.
  5. It will select the entire document due to editor.action.selectAll firing, instead of only the contents of the Mermaid diagram as we have coded in Swimm.

It seems like editor.action.selectAll is basically missing a when expression, which I think should be editorFocus. Adding that in the user keyboard shortcuts fixes the issue. And you can try that yourself using the same steps to reproduce.

I tried to contribute a keybinding via our extension to fix this, but adding:

    {
        "key": "ctrl+a",
        "mac": "cmd+a",
        "command": "editor.action.selectAll",
        "when": "editorFocus" // Or "activeWebviewPanelId != 'swimm.editor'"
    },
    {
        "key": "ctrl+a",
        "mac": "cmd+a",
        "command": "-editor.action.selectAll"
    }

To our extension's package.json only resulted in disabling the select all shortcut entirely.

贡献者指南