When using the new LINE_COLUMN(), CALLER() etc. apis, they currently access cmView variable set in Editor component.
EditEvalRenderLoop component triggers first code evaluation before Editor renders, so it's unset and crashes. User has to make an edit (any edit) for things to work.
- What if
Editor re-renders, can callbacks refer to wrong view? Specifically after crash boundary?
|
const view = new EditorView({ state: startState, parent: editor.current }) |
|
// TODO these execute after first code evaluation, so if editor code |
|
// references cmView or calls WRITE etc. directly, it fails after reload. |
|
window.cmView = view |
- I think next step is separate construction of source location proxies like
LINE_COLUMN() from actions like .JUMP() or .WRITE(). The former can close over some higher EditEvalRenderLoop state (a ref? a promise?), only the latter should need a codemirror view.
- And/or a kludge: delay evaluation until Editor rendered and set
cmView?
- Make it a promise? Make whole API ({ WRITE, CALLER, ... }) exposed to evaluation a promise?
When using the new
LINE_COLUMN(),CALLER()etc. apis, they currently accesscmViewvariable set inEditorcomponent.EditEvalRenderLoopcomponent triggers first code evaluation beforeEditorrenders, so it's unset and crashes. User has to make an edit (any edit) for things to work.Editorre-renders, can callbacks refer to wrong view? Specifically after crash boundary?model-view-self-modify/index.html
Lines 343 to 346 in 3211191
LINE_COLUMN()from actions like.JUMP()or.WRITE(). The former can close over some higherEditEvalRenderLoopstate (a ref? a promise?), only the latter should need a codemirror view.cmView?