提交 1dc88b47 编写于 作者: J Johannes Rieken

fix #30769

上级 5dec86b8
......@@ -27,6 +27,7 @@ export class OneSnippet {
private _placeholderDecorations: Map<Placeholder, string>;
private _placeholderGroups: Placeholder[][];
private _placeholderGroupsIdx: number;
private _syntheticFinalPlaceholderIndexPool: number = 1 << 30;
private static readonly _decor = {
active: ModelDecorationOptions.register({ stickiness: TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges, className: 'snippet-placeholder' }),
......@@ -173,7 +174,7 @@ export class OneSnippet {
// through the placeholders in the correct order
for (const nestedPlaceholder of nested._snippet.placeholders) {
if (nestedPlaceholder.isFinalTabstop) {
nestedPlaceholder.index = placeholder.index + (nested._snippet.placeholders.length / 10);
nestedPlaceholder.index = placeholder.index + (this._syntheticFinalPlaceholderIndexPool-- / 10);
} else {
nestedPlaceholder.index = placeholder.index + (nestedPlaceholder.index / 10);
}
......
......@@ -433,5 +433,28 @@ suite('SnippetSession', function () {
session.prev();
assertSelections(editor, new Selection(1, 6, 1, 25));
});
test('Snippet placeholder index incorrect after using 2+ snippets in a row that each end with a placeholder, #30769', function () {
editor.getModel().setValue('');
editor.setSelection(new Selection(1, 1, 1, 1));
const session = new SnippetSession(editor, 'test ${1:replaceme}');
session.insert();
editor.trigger('test', 'type', { text: '1' });
editor.trigger('test', 'type', { text: '\n' });
assert.equal(editor.getModel().getValue(), 'test 1\n');
session.merge('test ${1:replaceme}');
editor.trigger('test', 'type', { text: '2' });
editor.trigger('test', 'type', { text: '\n' });
assert.equal(editor.getModel().getValue(), 'test 1\ntest 2\n');
session.merge('test ${1:replaceme}');
editor.trigger('test', 'type', { text: '3' });
editor.trigger('test', 'type', { text: '\n' });
assert.equal(editor.getModel().getValue(), 'test 1\ntest 2\ntest 3\n');
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册