Skip to content

loading race condition: ReferenceError: cmView is not defined #8

@cben

Description

@cben

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

  1. 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.
  2. 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions