From 2e9372a7fb885df7adbf3fa2c156f294761739b1 Mon Sep 17 00:00:00 2001 From: egamma Date: Thu, 9 Jul 2026 11:24:21 +0200 Subject: [PATCH] fix #315131: Completion-inserted `()` no longer tracked as auto-closed pair --- src/vs/editor/common/cursor/cursor.ts | 2 +- .../test/browser/controller/cursor.test.ts | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/vs/editor/common/cursor/cursor.ts b/src/vs/editor/common/cursor/cursor.ts index c1eb59282ffead..44fec5ea9971a8 100644 --- a/src/vs/editor/common/cursor/cursor.ts +++ b/src/vs/editor/common/cursor/cursor.ts @@ -466,7 +466,7 @@ export class CursorsController extends Disposable { public executeEdits(eventsCollector: ViewModelEventsCollector, source: string | null | undefined, edits: IIdentifiedSingleEditOperation[], cursorStateComputer: ICursorStateComputer, reason: TextModelEditSource): void { let autoClosingIndices: [number, number][] | null = null; - if (source === 'snippet') { + if (source === 'snippet' || source === 'suggest') { autoClosingIndices = this._findAutoClosingPairs(edits); } diff --git a/src/vs/editor/test/browser/controller/cursor.test.ts b/src/vs/editor/test/browser/controller/cursor.test.ts index 61ddc81e06d4b0..96f86a7ed005a1 100644 --- a/src/vs/editor/test/browser/controller/cursor.test.ts +++ b/src/vs/editor/test/browser/controller/cursor.test.ts @@ -5759,6 +5759,26 @@ suite('Editor Controller', () => { }); }); + test('issue #315131 - Completion-inserted () tracked as auto-closed pair when source is suggest', () => { + usingCursor({ + text: [ + 'math.fl' + ], + languageId: autoClosingLanguageId + }, (editor, model, viewModel) => { + viewModel.setSelections('test', [new Selection(1, 8, 1, 8)]); + + // Simulate a suggest completion that inserts 'floor()' with cursor between parens + viewModel.executeEdits('suggest', [{ range: new Range(1, 6, 1, 8), text: 'floor()' }], () => [new Selection(1, 11, 1, 11)], EditSources.suggest({ providerId: undefined })); + assert.strictEqual(model.getLineContent(1), 'math.floor()'); + assertCursor(viewModel, new Position(1, 11)); + + // Backspace should delete both parens since they are tracked as an auto-closed pair + editor.runCommand(CoreEditingCommands.DeleteLeft, null); + assert.strictEqual(model.getLineContent(1), 'math.floor'); + }); + }); + test('issue #78833 - Add config to use old brackets/quotes overtyping', () => { usingCursor({ text: [