In collaborative mode, I use Decorations to display other users’ cursors, but the refresh of Decorations needs to be done after the view is updated, so when typing fast, the cursor will shake, that is to say, the content is updated first, and then the cursor moves backwards
Why is that?
If the official example is the same, when two users are editing the same document, the update method of the plug-in needs to be called after the receiveUpdates function is called. At this time, the Decorations will be updated.
The code in the screenshot will not cause visual jitter—a view plugin’s
update method is called as part of the DOM update, and will immediately affect the next frame.
Yes, this will not cause visual jitter, but when multiple people edit a document collaboratively, user A will immediately remap the cursor position of user B after editing, and at this time, if user B also edits the document, Then the cursor position of user B needs to be moved again compared with that of user A. At this time, because user B edited the document, the content of document A has also changed, which seems to cause jitter.
That is to say, when the local update and receiving a remote update are triggered at the same time, the cursor position mapping will be performed twice, which will cause the jitter of the view