Sworld

Sworld

The only way to do great work is to love what you do.

解决Github Copilot补全冲突

近期在使用 Github Copilot 时,发现在面对 NES (Next Edit Suggestions) 补全时,按下 Tab 键经常会出现空格,而非跳转到目标位置,经过一番排查,发现这是因为 VSCode 的 Tab 键绑定冲突导致的,本文记录下解决方法。

错误表现#

在使用 Github Copilot 进行代码补全时,按下 Tab 键并没有跳转到补全建议的位置,而是插入了空格,导致无法顺利接受补全建议,如下图:

产生提示
Tab 后产生空格

调试思路#

首先我们启动 VSCode 的键盘快捷键调试功能,按下Ctrl + Shift + P搜索shortcut troubleshooting,打开快捷键调试面板。

check1

发现类似下方的信息:

check2

2025-10-18 15:58:06.749 [info] [窗口] [KeybindingService]: / Received  keydown event - modifiers: [], code: Tab, keyCode: 9, key: Tab
2025-10-18 15:58:06.749 [info] [窗口] [KeybindingService]: | Converted keydown event - modifiers: [], code: Tab, keyCode: 2 ('Tab')
2025-10-18 15:58:06.749 [info] [窗口] [KeybindingService]: | Resolving Tab
2025-10-18 15:58:06.749 [info] [窗口] [KeybindingService]: \ From 14 keybinding entries, matched tabout, when: editorTextFocus && !editorHasMultipleSelections && !inSnippetMode && !inlineSuggestionVisible && !suggestWidgetVisible, source: user extension albert.TabOut.
2025-10-18 15:58:06.749 [info] [窗口] [KeybindingService]: + Invoking command tabout.

显然,Tab 键被TabOut插件占用了。

解决方法#

此时我们可以使用Ctrl + K Ctrl + S打开键盘快捷键设置,搜索"Tab",找到TabOut: Tab Out,点击右侧的垃圾桶图标删除该快捷键绑定。

不过也有更好的办法,就是为 TabOut插件设置一个条件,使其在 Github Copilot 补全建议出现时不生效。我们可以将其when条件末尾追加!inlineEditIsVisible条件,最终得到该条件editorTextFocus && !editorHasMultipleSelections && !inSnippetMode && !inlineSuggestionVisible && !suggestWidgetVisible && !inlineEditIsVisible (编辑后按回车保存)。

现在,就能够正常补全了:

example3

example4

结束后重新按下Ctrl + Shift + P搜索shortcut troubleshooting以关闭快捷键调试面板。

加载中...
此文章数据所有权由区块链加密技术和智能合约保障仅归创作者所有。