From 49e570e136d8416cc794f46794ce75d09de5ad5a Mon Sep 17 00:00:00 2001 From: jmdowns2 Date: Thu, 12 Oct 2017 13:26:55 -0400 Subject: [PATCH] Fix for #32342 (#35463) * 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. --- extensions/emmet/src/abbreviationActions.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/extensions/emmet/src/abbreviationActions.ts b/extensions/emmet/src/abbreviationActions.ts index c0d3758abdb..2cf7e0501de 100644 --- a/extensions/emmet/src/abbreviationActions.ts +++ b/extensions/emmet/src/abbreviationActions.ts @@ -139,7 +139,14 @@ export function expandEmmetAbbreviation(args): Thenable { return [new vscode.Range(abbreviationRange.start.line, abbreviationRange.start.character, abbreviationRange.end.line, abbreviationRange.end.character), abbreviation, filter]; }; - editor.selections.forEach(selection => { + let selectionsInReverseOrder = editor.selections.slice(0); + selectionsInReverseOrder.sort((a, b) => { + var posA = a.isReversed ? a.anchor : a.active; + var posB = b.isReversed ? b.anchor : b.active; + return posA.compareTo(posB) * -1; + }); + + selectionsInReverseOrder.forEach(selection => { let position = selection.isReversed ? selection.anchor : selection.active; let [rangeToReplace, abbreviation, filter] = getAbbreviation(editor.document, selection, position, syntax); if (!rangeToReplace) { -- GitLab