Visitar URL original
Track auto-closed pairs for edits inserted by suggestions by alexdima · Pull Request #348081 · microsoft/vscode · GitHub
Skip to content

Track auto-closed pairs for edits inserted by suggestions - #348081

Merged
Alexandru Dima (alexdima) merged 1 commit into
mainfrom
agents/fix-315131-suggest-autoclose
Nov 13, 2026
Merged

Alexandru Dima (alexdima) merged 1 commit into
mainfrom
agents/fix-315131-suggest-autoclose

Conversation

@alexdima

Copy link
Copy Markdown
Member

Fixes #315131

When a completion inserts a call like floor() with the cursor between the parens (a snippet completion floor($0), Pylance's completeFunctionParens, rust-analyzer, ...), pressing Backspace leaves floor) instead of deleting both parens, and typing ) no longer overtypes the inserted one. The same edit inserted with Insert Snippet still works.

Cause

Cursor.executeEdits registers inserted auto-closing pairs (_findAutoClosingPairs, added for #78975) only when the edit source is 'snippet'. Since #252666 the suggest controller passes EditSources.suggest(...) as the reason, so completion edits reach the cursor with source 'suggest' and the pairs are never tracked.

Change

Also find auto-closing pairs when the source is 'suggest'. EditSources.suggest is only used by the suggest controller, so this only affects edits from accepting a completion, the same edits that were tracked before #252666.

Demo

Same scenario (user snippet floor($0) in a JS file: first through Insert Snippet, then picked from suggest, then Backspace), on the installed Insiders 1.147.0 (before) and on a build of this branch (after).

Tests

  • ./scripts/test.sh --no-sandbox --run src/vs/editor/test/browser/controller/cursor.test.ts --grep "315131|78975|uto": 45 passing with the fix; without the cursor.ts change the new test issue #315131 - Parentheses inserted by a suggestion are tracked as auto-closed fails (floor) vs floor).
  • pnpm run oxlint on both changed files: clean.
  • validate-ui-scenario: fails at "Backspace: both parens should go" on Insiders 1.147.0, passes with --dev on this branch.

Before / after

Before

315131-before-insiders.mp4

After

315131-after-dev.mp4

🤖 Authored with GitHub Copilot on behalf of Alexandru Dima (@alexdima).

Since suggestions pass the 'suggest' edit source, parentheses inserted by a
completion (such as foo()) were no longer tracked as auto-closed, so Backspace
and overtyping no longer handled the closing character.

Fixes #315131

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 13, 2026 08:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the change restoring auto-closing pair tracking after accepted completions.

No open issues 🎉

What changed in this PR

Restores auto-closing pair tracking for accepted completions, fixing the regression described in #315131. Suggestion-inserted parentheses now use the same tracking as snippet edits, restoring paired Backspace deletion and closing-parenthesis overtyping.

Changes:

  • Includes 'suggest' edits in existing auto-closing pair detection.
  • Adds a regression test verifying that Backspace deletes both suggestion-inserted parentheses.

No actionable findings remain.

File Description
src/​vs/​editor/​test/​browser/​controller/​cursor.test.ts Tests paired Backspace deletion after a suggestion inserts floor().
src/​vs/​editor/​common/​cursor/​cursor.ts Enables auto-closing pair detection for suggestion edits.

Review effort: Balanced

@alexdima
Alexandru Dima (alexdima) merged commit 65d8f20 into main Nov 13, 2026
53 of 54 checks passed
@alexdima
Alexandru Dima (alexdima) deleted the agents/fix-315131-suggest-autoclose branch November 13, 2026 10:32
@vs-code-engineering vs-code-engineering Bot added this to the 1.147.0 milestone Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Completion-inserted () no longer tracked as auto-closed pair

4 participants