Skip to content

Commit ca14d90

Browse files
committed
Fix a crash in syntax-based indention
FIX: Fix a regression introduced 6.10.7 that caused indention to sometimes crash on nested language boundaries. Closes codemirror/dev#1494
1 parent 816c616 commit ca14d90

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/indent.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ function syntaxIndentation(cx: IndentContext, ast: Tree, pos: number) {
199199
let inner = ast.resolveInner(pos, -1).resolve(pos, 0).enterUnfinishedNodesBefore(pos)
200200
if (inner != stack.node) {
201201
let add = []
202-
for (let cur = inner; cur != stack.node; cur = cur.parent!) add.push(cur)
202+
for (let cur = inner; cur && !(cur.from == stack.node.from && cur.type == stack.node.type); cur = cur.parent!)
203+
add.push(cur)
203204
for (let i = add.length - 1; i >= 0; i--) stack = {node: add[i], next: stack}
204205
}
205206
return indentFor(stack, cx, pos)

0 commit comments

Comments
 (0)