Skip to content

Commit 310e46e

Browse files
committed
Prevent StreamParser from reusing trees that start in the wrong place
FIX: Fix an issue where a `StreamLanguage` could get confused when trying to reuse existing parse data when the parsed range changed. codemirror/dev#1476
1 parent a7a19f5 commit 310e46e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/stream-parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function findState<State>(
153153

154154
function cutTree(lang: StreamLanguage<unknown>, tree: Tree, from: number, to: number, inside: boolean): Tree | null {
155155
if (inside && from <= 0 && to >= tree.length) return tree
156-
if (!inside && tree.type == lang.topNode) inside = true
156+
if (!inside && from == 0 && tree.type == lang.topNode) inside = true
157157
for (let i = tree.children.length - 1; i >= 0; i--) {
158158
let pos = tree.positions[i], child = tree.children[i], inner
159159
if (pos < to && child instanceof Tree) {

0 commit comments

Comments
 (0)