Skip to content

Commit

Permalink
Fix infinite loop in commands
Browse files Browse the repository at this point in the history
FIX: Fix an infinite loop caused by `insertNewlineContinueMarkup`.

Closes codemirror/dev#1502
  • Loading branch information
marijnh committed Jan 9, 2025
1 parent 2e7fa06 commit df90d98
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ function nonTightList(node: SyntaxNode, doc: Text) {
function blankLine(context: Context[], state: EditorState, line: Line) {
let insert = ""
for (let i = 0, e = context.length - 2; i <= e; i++) {
insert += context[i].blank(i < e ? countColumn(line.text, 4, context[i + 1].from) - insert.length : null, i < e)
insert += context[i].blank(i < e
? countColumn(line.text, 4, Math.min(line.text.length, context[i + 1].from)) - insert.length
: null, i < e)
}
return normalizeIndent(insert, state)
}
Expand Down

0 comments on commit df90d98

Please sign in to comment.