I created a custom command to select all text and bound it to Mod-a
.
keymap({
'Mod-a': (state, dispatch) => {
const from = 0
const to = state.doc.content.size
const selection = TextSelection.create(state.doc, from, to)
const tr = state.tr.setSelection(selection)
dispatch(tr)
return true
}
})
This works fine most of the time. But there is one single edge case.
- select all text with
Mod-a
- type
a
- select all text with
Mod-a
again - type
a
- see error:
RangeError: Position -1 out of range
This only happens if I replace a single letter with the same single letter.
There is no error if I replace a
with b
for example.
Video:
Glitch demo:
I think this is a bug or have I missed something obvious?