Extract getInsertionPositions

This commit is contained in:
Matt Bierner
2018-07-11 08:56:57 -07:00
parent 6c99578088
commit bd3beec042

View File

@@ -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 {