diff --git a/extensions/typescript-language-features/src/features/tagCompletion.ts b/extensions/typescript-language-features/src/features/tagCompletion.ts index 3843c486f87..66af4920ef9 100644 --- a/extensions/typescript-language-features/src/features/tagCompletion.ts +++ b/extensions/typescript-language-features/src/features/tagCompletion.ts @@ -114,13 +114,9 @@ class TagClosing { const activeDocument = activeEditor.document; if (document === activeDocument && activeDocument.version === version) { - const selections = activeEditor.selections; - const snippet = this.getTagSnippet(body); - if (selections.length && selections.some(s => s.active.isEqual(position))) { - activeEditor.insertSnippet(snippet, selections.map(s => s.active)); - } else { - activeEditor.insertSnippet(snippet, position); - } + activeEditor.insertSnippet( + this.getTagSnippet(body), + this.getInsertionPositions(activeEditor, position)); } }, 100); } @@ -131,6 +127,13 @@ class TagClosing { snippet.appendText(closingTag.newText); return snippet; } + + private getInsertionPositions(editor: vscode.TextEditor, position: vscode.Position) { + const activeSelectionPositions = editor.selections.map(s => s.active); + return activeSelectionPositions.some(p => p.isEqual(position)) + ? activeSelectionPositions + : position; + } } export class ActiveDocumentDependentRegistration {