aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/snippets.ts10
1 files changed, 5 insertions, 5 deletions
diff --git a/editors/code/src/snippets.ts b/editors/code/src/snippets.ts
index dc53ebe2e..9561aa345 100644
--- a/editors/code/src/snippets.ts
+++ b/editors/code/src/snippets.ts
@@ -29,7 +29,7 @@ async function editorFromUri(uri: vscode.Uri): Promise<vscode.TextEditor | undef
29} 29}
30 30
31export async function applySnippetTextEdits(editor: vscode.TextEditor, edits: vscode.TextEdit[]) { 31export async function applySnippetTextEdits(editor: vscode.TextEditor, edits: vscode.TextEdit[]) {
32 let selection: vscode.Selection | undefined = undefined; 32 const selections: vscode.Selection[] = [];
33 let lineDelta = 0; 33 let lineDelta = 0;
34 await editor.edit((builder) => { 34 await editor.edit((builder) => {
35 for (const indel of edits) { 35 for (const indel of edits) {
@@ -44,18 +44,18 @@ export async function applySnippetTextEdits(editor: vscode.TextEditor, edits: vs
44 indel.range.start.character + placeholderStart 44 indel.range.start.character + placeholderStart
45 : prefix.length - lastNewline - 1; 45 : prefix.length - lastNewline - 1;
46 const endColumn = startColumn + placeholderLength; 46 const endColumn = startColumn + placeholderLength;
47 selection = new vscode.Selection( 47 selections.push(new vscode.Selection(
48 new vscode.Position(startLine, startColumn), 48 new vscode.Position(startLine, startColumn),
49 new vscode.Position(startLine, endColumn), 49 new vscode.Position(startLine, endColumn),
50 ); 50 ));
51 builder.replace(indel.range, newText); 51 builder.replace(indel.range, newText);
52 } else { 52 } else {
53 lineDelta = countLines(indel.newText) - (indel.range.end.line - indel.range.start.line);
54 builder.replace(indel.range, indel.newText); 53 builder.replace(indel.range, indel.newText);
55 } 54 }
55 lineDelta = countLines(indel.newText) - (indel.range.end.line - indel.range.start.line);
56 } 56 }
57 }); 57 });
58 if (selection) editor.selection = selection; 58 if (selections.length > 0) editor.selections = selections;
59} 59}
60 60
61function parseSnippet(snip: string): [string, [number, number]] | undefined { 61function parseSnippet(snip: string): [string, [number, number]] | undefined {