Skip to content

Commit

Permalink
Fix bug where editor would freeze when block of code was deleted (#2539)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cosmin-Mare authored Nov 3, 2024
1 parent d0b6c32 commit dcba25c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/codemirror/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ export const collapseRanges = (view: EditorView, ranges: [number, number][]) =>
for (let pos = start; pos < end;) {
const line = view.lineBlockAt(pos)
const range = foldable(view.state, line.from, line.to)
if (range) effects.push(foldEffect.of(range))
pos = (range ? view.lineBlockAt(range.to) : line).to + 1
if (!range) break;

effects.push(foldEffect.of(range))
pos = view.lineBlockAt(range.to).to + 1
}
}

Expand Down

0 comments on commit dcba25c

Please sign in to comment.