diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 5c79774073f..589b030d686 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -619,13 +619,7 @@ namespace ts { // be parented by the container of the SyntaxList, not the SyntaxList itself. // In order to find the list item index, we first need to locate SyntaxList itself and then search // for the position of the relevant node (or comma). - const syntaxList = forEach(node.parent.getChildren(), c => { - // find syntax list that covers the span of the node - if (isSyntaxList(c) && c.pos <= node.pos && c.end >= node.end) { - return c; - } - }); - + const syntaxList = find(node.parent.getChildren(), (c): c is SyntaxList => isSyntaxList(c) && rangeContainsRange(c, node)); // Either we didn't find an appropriate list, or the list must contain us. Debug.assert(!syntaxList || contains(syntaxList.getChildren(), node)); return syntaxList;