mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-21 17:19:01 +01:00
Extract getInsertionPositions
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user