about summary refs log tree commit diff
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 dc53ebe2eeb..c8e71341a7d 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
 }
 
 export async function applySnippetTextEdits(editor: vscode.TextEditor, edits: vscode.TextEdit[]) {
-    let selection: vscode.Selection | undefined = undefined;
+    let selections: vscode.Selection[] = [];
     let lineDelta = 0;
     await editor.edit((builder) => {
         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 {