From 8b28e313fd401a1e5e675e38490552fb9c469a40 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Tue, 17 Dec 2024 09:21:17 +0100 Subject: [PATCH] Improve behavior of syntax indentation on language boundaries FIX: Make sure the inner mode gets a chance to indent when indenting right at the end of a nested language section. See https://discuss.codemirror.net/t/python-fencedcode-indentation-inconsistent/8909 --- src/indent.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/indent.ts b/src/indent.ts index 7fd4972..7851fa1 100644 --- a/src/indent.ts +++ b/src/indent.ts @@ -196,7 +196,7 @@ export const indentNodeProp = new NodeProp<(context: TreeIndentContext) => numbe // Compute the indentation for a given position from the syntax tree. function syntaxIndentation(cx: IndentContext, ast: Tree, pos: number) { let stack = ast.resolveStack(pos) - let inner = stack.node.enterUnfinishedNodesBefore(pos) + let inner = ast.resolveInner(pos, -1).resolve(pos, 0).enterUnfinishedNodesBefore(pos) if (inner != stack.node) { let add = [] for (let cur = inner; cur != stack.node; cur = cur.parent!) add.push(cur)