Skip to content

Commit 75fa945

Browse files
author
Andy
authored
Simplify findContainingList (#22128)
1 parent 73947b6 commit 75fa945

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/services/utilities.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -619,13 +619,7 @@ namespace ts {
619619
// be parented by the container of the SyntaxList, not the SyntaxList itself.
620620
// In order to find the list item index, we first need to locate SyntaxList itself and then search
621621
// for the position of the relevant node (or comma).
622-
const syntaxList = forEach(node.parent.getChildren(), c => {
623-
// find syntax list that covers the span of the node
624-
if (isSyntaxList(c) && c.pos <= node.pos && c.end >= node.end) {
625-
return c;
626-
}
627-
});
628-
622+
const syntaxList = find(node.parent.getChildren(), (c): c is SyntaxList => isSyntaxList(c) && rangeContainsRange(c, node));
629623
// Either we didn't find an appropriate list, or the list must contain us.
630624
Debug.assert(!syntaxList || contains(syntaxList.getChildren(), node));
631625
return syntaxList;

0 commit comments

Comments
 (0)