However, this brings a UI glitch to users. I noticed that if I fake a text edit with something like this:
editor.dispatch({ changes: { from: 0, insert: ' ' } }); // undo the change later
The editor will perform the layout earlier, and it “fixes” the issue. I know this is not the ideal way to trigger a layout, do you have any recommendations that I am not aware of?
Could it be that your fonts or styles are loading after the editor initializes? A view.requestMeasure() should cause it to re-measure its layout. Sometimes it helps to do this on a "load" event.
If you can simplify the case where the editor loads up incorrectly to an HTML/JS page that uses no dependencies beyond CodeMirror, I’ll gladly debug it.
Thanks for being so kind. This is a good point, I don’t use other dependencies, but the project is getting a bit complicated now, I think a minimal repro would help me understand the issue better.