Skip to content

Commit d2ce942

Browse files
committed
1 parent 51670ce commit d2ce942

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

src/vs/editor/contrib/snippet/browser/snippetParser.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,7 @@ export function walk(marker: Marker[], visitor: (marker: Marker) => boolean): vo
229229
if (!recurse) {
230230
break;
231231
}
232-
if (marker instanceof Placeholder || marker instanceof Variable) {
233-
stack.unshift(...marker.children);
234-
}
232+
stack.unshift(...marker.children);
235233
}
236234
}
237235

@@ -366,13 +364,14 @@ export class SnippetParser {
366364
// like `${1:foo}and$1` becomes ${1:foo}and${1:foo}
367365
if (!placeholderDefaultValues.has(thisMarker.index)) {
368366
placeholderDefaultValues.set(thisMarker.index, thisMarker.children);
367+
walk(thisMarker.children, placeholderDefaultValues);
368+
369369
} else if (thisMarker.children.length === 0) {
370+
// copy children from first placeholder definition, no need to
371+
// recurse on them because they have been visited already
370372
thisMarker.children = placeholderDefaultValues.get(thisMarker.index).slice(0);
371373
}
372374

373-
if (thisMarker.children.length > 0) {
374-
walk(thisMarker.children, placeholderDefaultValues);
375-
}
376375

377376
} else if (thisMarker instanceof Variable) {
378377
walk(thisMarker.children, placeholderDefaultValues);

src/vs/editor/contrib/snippet/test/browser/snippetParser.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,4 +389,8 @@ suite('SnippetParser', () => {
389389

390390
assert.equal(Placeholder.compareByIndex(_10, _2), 1);
391391
});
392+
393+
test('Maximum call stack size exceeded, #28983', function () {
394+
new SnippetParser().parse('${1:${foo:${1}}}');
395+
});
392396
});

0 commit comments

Comments
 (0)