xshoji's blog

VSCode: Copilot Chat のペインで上下キーでの履歴移動とEnterキーでの送信を無効化して使いやすくする

VSCodeの Copilot Chat のペインでAIへ指示する際、イラっとする動きをすることが2点ほどありました。具体的には

  • 上下でカーソル移動する際に、1行目で↑キーを押すと前に送信した文章が表示されてしまう(履歴移動になる)
  • まだ入力中なのに間違えてEnterで送信してしまう

という点です。今回はこれらの解消方法を見つけたので紹介します。

上下キーでの履歴移動を無効化する

Here are the keybindings to disable it in chat but keep it elsewhere https://github.com/microsoft/vscode/issues/282902#issuecomment-3644365381

にある通り、以下の設定を keybindings.json に追加します。

( keybindings.json の開き方は、 過去記事 に手順を載せてるので参考にしてみてください)

    {
        "command": "-history.showPrevious",
        "key": "up"
    },
    {
        "command": "-history.showNext",
        "key": "down"
    },
    {
        "command": "history.showPrevious",
        "key": "up",
        "when": "historyNavigationBackwardsEnabled && historyNavigationWidgetFocus && !isComposing && !suggestWidgetVisible && !inChat"
    },
    {
        "command": "history.showNext",
        "key": "down",
        "when": "historyNavigationForwardsEnabled && historyNavigationWidgetFocus && !isComposing && !suggestWidgetVisible && !inChat"
    }

Enterで送信を無効化する(Cmd + Enterで送信するようにする)

https://github.com/orgs/community/discussions/86624#discussioncomment-12870557

にある回答を参考に、以下の設定を keybindings.json に追加します。

    // Disable Enter key to submit in VSCode Copilot Chat input box
    {
        "key": "cmd+enter",
        "command": "workbench.action.chat.submit",
        "when": "chatInputHasText && inChatInput && !chatSessionRequestInProgress && !withinEditSessionDiff"
    },
    {
        "key": "enter",
        "command": "-workbench.action.chat.submit",
        "when": "chatInputHasText && inChatInput && !chatSessionRequestInProgress && !withinEditSessionDiff"
    },

まとめ

これで、イライラする動作を解消でき、快適に Copilot Chat に指示を出せるようになりました!!