Skip to content

Commit 49e570e

Browse files
jmdowns2ramya-rao-a
authored andcommitted
* When expanding abbreviations, do so from bottom to top. This way a change higher up will not interfere with text below. * When expanding abbreviations, do so from bottom to top. This way a change higher up will not interfere with text below.
1 parent fcf92f6 commit 49e570e

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

extensions/emmet/src/abbreviationActions.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,14 @@ export function expandEmmetAbbreviation(args): Thenable<boolean> {
139139
return [new vscode.Range(abbreviationRange.start.line, abbreviationRange.start.character, abbreviationRange.end.line, abbreviationRange.end.character), abbreviation, filter];
140140
};
141141

142-
editor.selections.forEach(selection => {
142+
let selectionsInReverseOrder = editor.selections.slice(0);
143+
selectionsInReverseOrder.sort((a, b) => {
144+
var posA = a.isReversed ? a.anchor : a.active;
145+
var posB = b.isReversed ? b.anchor : b.active;
146+
return posA.compareTo(posB) * -1;
147+
});
148+
149+
selectionsInReverseOrder.forEach(selection => {
143150
let position = selection.isReversed ? selection.anchor : selection.active;
144151
let [rangeToReplace, abbreviation, filter] = getAbbreviation(editor.document, selection, position, syntax);
145152
if (!rangeToReplace) {

0 commit comments

Comments
 (0)