y-monaco
y-monaco copied to clipboard
Fix incorrect remote selection after undo/redo
This PR is to resolve issue #19.
The root cause is on the monaco-editor
side, which is related to the incorrect event order of onDidChangeModelContent
and onDidChangeCursorSelection
on undo/redo. Please refer to https://github.com/microsoft/monaco-editor/issues/2774 for more details.
- Refactored some code into function
_monacoSelectionChangeHandler
- Added a workaround to make sure "selection changes" always happen after "content changes"
Before:
https://github.com/yjs/y-monaco/assets/11325684/a7eedb44-bff6-4392-ab59-9f050bc8c276
After:
https://github.com/yjs/y-monaco/assets/11325684/21c9cb7d-44c0-49f4-831b-057323e2a55b
Submitted with StackBlitz.