diff --git a/src/tree-sitter-language-mode.js b/src/tree-sitter-language-mode.js index 218f41cd5..8344c89a5 100644 --- a/src/tree-sitter-language-mode.js +++ b/src/tree-sitter-language-mode.js @@ -571,7 +571,25 @@ class LanguageLayer { } } - _rangesForInjectionNode (node) { + /** + * @param node {Parser.SyntaxNode} + * @param fromChildrenOfType {Object} + */ + _rangesForInjectionNode (node, fromChildrenOfType) { + if (!fromChildrenOfType) + return this._textRangesForInjectionNode(node) + const ranges = [] + for (const child of node.namedChildren) { + if (fromChildrenOfType[child.type]) + ranges.push(...this._textRangesForInjectionNode(child)) + } + return ranges + } + + /** + * @param node {Parser.SyntaxNode} + */ + _textRangesForInjectionNode (node) { const result = [] let position = node.startPosition let index = node.startIndex