diff --git a/src/pyj/read_book/search_worker.pyj b/src/pyj/read_book/search_worker.pyj index 2b2bbf45ab..53534ba7e5 100644 --- a/src/pyj/read_book/search_worker.pyj +++ b/src/pyj/read_book/search_worker.pyj @@ -77,9 +77,9 @@ class ToCOffsetMap: while parent?: ancestors.push(parent) parent = self.parent_map[parent.id] - if len(ancestors) > 1: - ancestors.pop() # root node - for v'var i = ancestors.length; i-- > 0;': + if ancestors.length > 1: + # last item in ancestors is the root node + for v'var i = ancestors.length - 1; i-- > 0;': ans.push(ancestors[i].id) ans.push(node.id) return ans