Cursor moves to start of line


I have built quite a complex app with Codemirror as part of it. I’m trying to debug an issue with the cursor moving to the start of the line and hoping for a pointer in the right direction.

When a user types an EditorView.updateListener.of((view: ViewUpdate) callback is triggered and does a number of things. Mostly involving setting some state in Recoil.js. It works fine until I add another RecoilRoot that triggers a DOM update in a component. The Codemirror component is definitely not rerendering and the view reports this

docChanged: true, 
empty: false, 
focusChanged: false, 
geometryChanged: true, 
heightChanged: true,
selectionSet: false, 
viewportChanged: true

and these all match what is reported without setting the Recoil state.

I was wondering if you were aware of anything that would cause the cursor to jump to start of the line rather than the start of the document. I’m finding it hard to find where the difference is occurring.


This doesn’t ring a bell. If you can show the problem occurring in a minimal CodeMirror-only script, I can gladly try to debug it.

I narrowed it down to this lib

That I was using in the presentation area of the app.

Thanks again for your time.

Oh, right, external CodeMirror-unaware libs that directly mess with the editable DOM are not something you can expect to work with CodeMirror.

1 Like