Adding text selection/highlight to SplitView

Hello, I am working on Masters Thesis where I’m building a code editor for undergrad students. I got the code for Split View to work (CodeMirror Split View Example) however can someone provide sample code on how to also share text highlight and cursor location between two views? So when a user selects text in one view, the same selection shows in the second view. Same for cursor location.

Thanks,
Rey

I’m not going to write out the code for you, but the basic idea would be to change syncDispatch to also forward selection changes to the other editor.

Hi Marijn,

Thanks for the response. I really appreciate it. In the code, I see that changes are being applied to the second view[1] using the code below:

views[to].dispatch({changes: tr.changes, annotations: syncAnnotation.of(true)})

However I can’t seem to locate where the selected text parameters are stored inside the the first view (view[0]) ?

Also, I can’t seem to figure out how to pass the selection parameters to the second view (view[1]).

I read through documentation and saw that there is TransactionSpec and effects property which maybe is the right thing to use for this?