y-monaco icon indicating copy to clipboard operation
y-monaco copied to clipboard

Fix incorrect remote selection after undo/redo

Open mosquitochang opened this issue 1 year ago • 0 comments

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


Review PR in StackBlitz Submitted with StackBlitz.

mosquitochang avatar Jan 30 '24 09:01 mosquitochang