提交 3a9a7f96 编写于 作者: J Johannes Rieken

fix #58736

上级 e0b1ed72
......@@ -158,7 +158,13 @@ export abstract class Marker {
const newChildren = parent.children.slice(0);
newChildren.splice(idx, 1, ...others);
parent._children = newChildren;
others.forEach(node => node.parent = parent);
(function _fixParent(children: Marker[], parent: Marker) {
for (const child of children) {
child.parent = parent;
_fixParent(child.children, child);
}
})(others, parent);
}
get children(): Marker[] {
......
......@@ -723,4 +723,30 @@ suite('SnippetParser', () => {
test('snippets variable not resolved in JSON proposal #52931', function () {
assertTextAndMarker('FOO${1:/bin/bash}', 'FOO/bin/bash', Text, Placeholder);
});
test('Mirroring sequence of nested placeholders not selected properly on backjumping #58736', function () {
let snippet = new SnippetParser().parse('${3:nest1 ${1:nest2 ${2:nest3}}} $3');
assert.equal(snippet.children.length, 3);
assert.ok(snippet.children[0] instanceof Placeholder);
assert.ok(snippet.children[1] instanceof Text);
assert.ok(snippet.children[2] instanceof Placeholder);
function assertParent(marker: Marker) {
marker.children.forEach(assertParent);
if (!(marker instanceof Placeholder)) {
return;
}
let found = false;
let m: Marker = marker;
while (m && !found) {
if (m.parent === snippet) {
found = true;
}
m = m.parent;
}
assert.ok(found);
}
let [, , clone] = snippet.children;
assertParent(clone);
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册