提交 e098262d 编写于 作者: J Johannes Rieken

fix #58267

上级 c743483e
......@@ -220,9 +220,11 @@ export class OneSnippet {
// Massage placeholder-indicies of the nested snippet to be
// sorted right after the insertion point. This ensures we move
// through the placeholders in the correct order
const indexLastPlaceholder = nested._snippet.placeholderInfo.last.index;
for (const nestedPlaceholder of nested._snippet.placeholderInfo.all) {
if (nestedPlaceholder.isFinalTabstop) {
nestedPlaceholder.index = placeholder.index + ((nested._snippet.placeholderInfo.last.index + 1) / this._nestingLevel);
nestedPlaceholder.index = placeholder.index + ((indexLastPlaceholder + 1) / this._nestingLevel);
} else {
nestedPlaceholder.index = placeholder.index + (nestedPlaceholder.index / this._nestingLevel);
}
......
......@@ -317,4 +317,34 @@ suite('SnippetController2', function () {
ctrl.next();
assertContextKeys(contextKeys, true, true, true);
});
test('Placeholders order #58267', function () {
const ctrl = new SnippetController2(editor, logService, contextKeys);
model.setValue('');
editor.setSelection(new Selection(1, 1, 1, 1));
ctrl.insert('\\pth{$1}$0');
assertSelections(editor, new Selection(1, 6, 1, 6));
assertContextKeys(contextKeys, true, false, true);
ctrl.insert('\\itv{${1:left}}{${2:right}}{${3:left_value}}{${4:right_value}}$0');
assertSelections(editor, new Selection(1, 11, 1, 15));
ctrl.next();
assertSelections(editor, new Selection(1, 17, 1, 22));
ctrl.next();
assertSelections(editor, new Selection(1, 24, 1, 34));
ctrl.next();
assertSelections(editor, new Selection(1, 36, 1, 47));
ctrl.next();
assertSelections(editor, new Selection(1, 48, 1, 48));
ctrl.next();
assertSelections(editor, new Selection(1, 49, 1, 49));
assertContextKeys(contextKeys, false, false, false);
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册