From cd997e3d774b1bf2406862e12b2e799e4688dd07 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 16 Feb 2018 09:40:57 -0800 Subject: [PATCH] Simplify TreeSitterHighlightIterator.moveToSuccessor --- src/tree-sitter-language-mode.js | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/tree-sitter-language-mode.js b/src/tree-sitter-language-mode.js index 5a3984b62..5c6a91930 100644 --- a/src/tree-sitter-language-mode.js +++ b/src/tree-sitter-language-mode.js @@ -420,7 +420,7 @@ class TreeSitterHighlightIterator { this.pushCloseTag() const {nextSibling} = this.currentNode - if (nextSibling) { + if (nextSibling && nextSibling.endIndex > this.currentIndex) { this.currentNode = nextSibling this.currentChildIndex++ if (this.currentIndex === nextSibling.startIndex) { @@ -434,19 +434,8 @@ class TreeSitterHighlightIterator { if (!this.currentNode) break } } - } else if (this.currentNode.startIndex < this.currentNode.endIndex) { - this.currentNode = this.currentNode.nextSibling - if (this.currentNode) { - this.currentChildIndex++ - this.currentPosition = this.currentNode.startPosition - this.currentIndex = this.currentNode.startIndex - this.pushOpenTag() - this.descendLeft() - } } else { - this.pushCloseTag() - this.currentNode = this.currentNode.parent - this.currentChildIndex = last(this.containingNodeChildIndices) + this.currentNode = this.currentNode.nextSibling } } while (this.closeTags.length === 0 && this.openTags.length === 0 && this.currentNode)