Skip to content

Commit

Permalink
Keep overwritable closed brackets on the line with the cursor
Browse files Browse the repository at this point in the history
FIX: Fix an issue that would prevent typing over closed brackets after starting
a new line with enter.

See https://discuss.codemirror.net/t/closebrackets-across-multiple-lines/7392
  • Loading branch information
marijnh committed Nov 9, 2023
1 parent 827d851 commit dc6fa51
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/closebrackets.ts
Expand Up @@ -42,10 +42,8 @@ const bracketState = StateField.define<RangeSet<typeof closedBracket>>({
create() { return RangeSet.empty },
update(value, tr) {
if (tr.selection) {
let lineStart = tr.state.doc.lineAt(tr.selection.main.head).from
let prevLineStart = tr.startState.doc.lineAt(tr.startState.selection.main.head).from
if (lineStart != tr.changes.mapPos(prevLineStart, -1))
value = RangeSet.empty
let line = tr.state.doc.lineAt(tr.selection.main.head)
value = value.update({filter: from => from >= line.from && from <= line.to})
}
value = value.map(tr.changes)
for (let effect of tr.effects) if (effect.is(closeBracketEffect))
Expand Down

0 comments on commit dc6fa51

Please sign in to comment.