Skip to content

Commit dc6fa51

Browse files
committed
Keep overwritable closed brackets on the line with the cursor
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
1 parent 827d851 commit dc6fa51

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/closebrackets.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ const bracketState = StateField.define<RangeSet<typeof closedBracket>>({
4242
create() { return RangeSet.empty },
4343
update(value, tr) {
4444
if (tr.selection) {
45-
let lineStart = tr.state.doc.lineAt(tr.selection.main.head).from
46-
let prevLineStart = tr.startState.doc.lineAt(tr.startState.selection.main.head).from
47-
if (lineStart != tr.changes.mapPos(prevLineStart, -1))
48-
value = RangeSet.empty
45+
let line = tr.state.doc.lineAt(tr.selection.main.head)
46+
value = value.update({filter: from => from >= line.from && from <= line.to})
4947
}
5048
value = value.map(tr.changes)
5149
for (let effect of tr.effects) if (effect.is(closeBracketEffect))

0 commit comments

Comments
 (0)