Skip to content

Commit 56a1c5f

Browse files
committed
Fix an issue in overlay tree traversal in indentation
FIX: Fix an issue where indentation would sometimes miss nodes in mixed-language situations.
1 parent 951477e commit 56a1c5f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/indent.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,10 @@ 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 && !(cur.from == stack.node.from && cur.type == stack.node.type); cur = cur.parent!)
203-
add.push(cur)
202+
for (let cur = inner; cur && !(
203+
cur.from < stack.node.from || cur.to > stack.node.to ||
204+
cur.from == stack.node.from && cur.type == stack.node.type
205+
); cur = cur.parent!) add.push(cur)
204206
for (let i = add.length - 1; i >= 0; i--) stack = {node: add[i], next: stack}
205207
}
206208
return indentFor(stack, cx, pos)

0 commit comments

Comments
 (0)