fix(vscode): stop autocomplete firing in non-code input boxes (#12933)#12942
fix(vscode): stop autocomplete firing in non-code input boxes (#12933)#12942minh2416294 wants to merge 1 commit into
Conversation
the inline completion provider is registered with a catch-all selector ({ pattern: '**' }) so it was running inside other extensions text inputs, including the copilot chat input. the handler only returned early for the vscode-scm scheme.
this adds a small denylist of non-code input schemes (chat, comment, output, settings) and skips completions there, plus folds in the existing vscode-scm guard. went with a denylist instead of narrowing the selector so it doesnt accidentally break vscode-remote, vscode-vfs, untitled and notebook docs.
Closes continuedev#12933
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
|
quick heads up on the red check, I think it looks unrelated to this change. the jetbrains-tests failure is the intellij integration test Autocomplete > testAutocomplete() (Autocomplete.kt:42). this PR only touches extensions/vscode/ (the completion provider + its test) so it cant affect the jetbrains plugin build, and that same test is failing on other open PRs right now that dont touch jetbrains either, so it seems pre-existing rather than caused by this change the vscode checks (vscode-checks, the autocomplete e2e, lint, prettier, the test matrix on all node versions) are all green. happy to dig in if you want but wanted to flag the red doesnt look like its from this PR. thank you guys! |
Description
Continue's VS Code inline autocomplete was firing inside other extensions' text input boxes - the reporter saw it autocomplete into the GitHub Copilot Chat input (#12933).
Root cause: the inline completion provider is registered with a catch-all document selector
[{ pattern: "**" }](extensions/vscode/src/extension/VsCodeExtension.ts), so VS Code invokes it for every document, including foreign chat/comment/output input boxes. The handlerprovideInlineCompletionItemsonly returned early for thevscode-scmscheme, so it had no general guard against non-code input surfaces. The Copilot Chat input is a real TextDocument with URI schemechatSessionInput, which slipped through and received completions.Fix: add a small handler-side guard that returns early for known non-code input schemes, extracted into a testable
isNonCodeInputScheme()helper. The existingvscode-scmbail is folded into the same denylist (behavior-preserving).I kept this as a scheme denylist rather than narrowing the registration selector to an allowlist, because an allowlist would risk silently regressing document types that work today -
vscode-remote(SSH/WSL/Codespaces),vscode-vfs(github.dev),untitledbuffers, and notebook cells. This also mirrors how VS Code's own Copilot completions guard their chat input by scheme, and matches existing scheme-guarding precedent in this repo (InlineTipManager, NextEditWindowManager, ideUtils)Checklist
I've read the contributing guide
The relevant docs, if any, have been updated or created (n/a — internal behavior fix)
The relevant tests, if any, have been updated or created.
Tests
Added unit tests in
ContinueCompletionProvider.vitest.ts:isNonCodeInputSchemereturns true for each denied scheme (vscode-scm, comment, chatSessionInput, vscode-interactive-input, vscode-chat-editor, chat-editing-text-model, output, vscode-settings) and false for real editable schemes (file, vscode-remote, untitled, vscode-notebook-cell, vscode-vfs).The provider returns null and does not start a completion chain for each denied scheme (parametrized), with a named case for the chatSessionInput scheme that reproduces Continue writes into Copilot Chat input #12933.
The existing "starts a new chain" test on a file:// document acts as the positive control, confirming real code files are unaffected.
Manual repro (autocomplete leaking into the Copilot Chat input) requires a build of the extension with Copilot installed; the behavior is otherwise fully covered by the unit tests above.