Skip to content

Commit

Permalink
Fix patch for supporting type-over closed brackets on new lines
Browse files Browse the repository at this point in the history
FIX: Fix a bug that caused typing over closed brackets after pressing enter to still
not work in many situations.

See https://discuss.codemirror.net/t/closebrackets-across-multiple-lines/7392/4
  • Loading branch information
marijnh committed Nov 10, 2023
1 parent beb3d9e commit ddebacc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/closebrackets.ts
Expand Up @@ -41,11 +41,11 @@ closedBracket.startSide = 1; closedBracket.endSide = -1
const bracketState = StateField.define<RangeSet<typeof closedBracket>>({
create() { return RangeSet.empty },
update(value, tr) {
value = value.map(tr.changes)
if (tr.selection) {
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))
value = value.update({add: [closedBracket.range(effect.value, effect.value + 1)]})
return value
Expand Down

0 comments on commit ddebacc

Please sign in to comment.