Closed felixroos closed 1 year ago
It seems this error is not catchable.. I think the issue is that codemirror still tries to highlight a region in the old document after it has been changed (from a longer document to a shorter one). I already tried to handle that case here, but the problem is that the length of the new document is not accessible in that callback..
@mindofmatthew do you have any idea how this could be fixed? It seems impossible to catch this error because it is not thrown in userland:
index.js:801 Uncaught RangeError: Position 534 is out of range for changeset of length 476
at ChangeSet.mapPos (index.js:801:19)
at findSharedChunks (index.js:3503:55)
at RangeSet.compare (index.js:3298:28)
at findChangedDeco (index.js:2955:14)
at DocView.update (index.js:2510:24)
at EditorView.update (index.js:6210:36)
at EditorView._dispatch (index.js:6092:59)
at EditorView.dispatch (index.js:6160:14)
at useCodeMirror.ts:156:12
at invokePassiveEffectCreate (react-dom.development.js:23487:20)
Might also make sense to get help on the codemirror forums..
this bug came back after a long holiday of not bugging
new repro: play a pattern, then delete everything while it's running
edit from the future: new repro: https://github.com/tidalcycles/strudel/issues/178#issuecomment-1614465496
this is a regression bug: after https://github.com/tidalcycles/strudel/pull/173 , range errors may crash codemirror component. Reproduction:
it seems this is a missing try catch somewhere inside ui/react-codemirror, probably also on the strudel side. Will need to investigate more.