From 201fbac8a97ba240ba6112c8f3ceca9ed1f23a3d Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Sat, 27 Mar 2021 18:50:55 +0100 Subject: Fix handling of multi-cursor snippets This allows one snippet per TextEdit, multiple in the same TextEdit are still broken --- editors/code/src/snippets.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/editors/code/src/snippets.ts b/editors/code/src/snippets.ts index dc53ebe2e..c8e71341a 100644 --- a/editors/code/src/snippets.ts +++ b/editors/code/src/snippets.ts @@ -29,7 +29,7 @@ async function editorFromUri(uri: vscode.Uri): Promise { for (const indel of edits) { @@ -44,18 +44,18 @@ export async function applySnippetTextEdits(editor: vscode.TextEditor, edits: vs indel.range.start.character + placeholderStart : prefix.length - lastNewline - 1; const endColumn = startColumn + placeholderLength; - selection = new vscode.Selection( + selections.push(new vscode.Selection( new vscode.Position(startLine, startColumn), new vscode.Position(startLine, endColumn), - ); + )); builder.replace(indel.range, newText); } else { - lineDelta = countLines(indel.newText) - (indel.range.end.line - indel.range.start.line); builder.replace(indel.range, indel.newText); } + lineDelta = countLines(indel.newText) - (indel.range.end.line - indel.range.start.line); } }); - if (selection) editor.selection = selection; + if (selections.length > 0) editor.selections = selections; } function parseSnippet(snip: string): [string, [number, number]] | undefined { -- cgit v1.2.3