-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Selection/cursor-change and edits racing condition #1
Comments
I noticed this issue too. The cursor is sometimes sent before the sharedb delta operation is updated. So it sometimes forces the cursor onto a new line or it hides the cursor. What do you think about this as a temp solution? the So the cursor updating is really dependent on So I reduced the timeout to 1ms. Basically always updating the cursor whenever operations have competed. This way the cursor always is updating right after the delta's have been applied. @pedrosanta In my testing it seems this solutions works better, and just wondering what your thoughts are? debouncedSendCursorData = utils.debounce((->
range = quill.getSelection()
if range
console.log '[cursors] Stopped typing, sending a cursor update/refresh.'
sendCursorData range
return
), 1)
doc.on 'nothing pending', debouncedSendCursorData
quill.on 'selection-change', (range, oldRange, source) ->
sendCursorData range
return |
But I do notice one downside is the constant sending of cursor data via sockets... Otherwise the cursor module shifts the cursor to the correct spot depending on the delta, not requiring the cursor update. So reducing the timeout does help cursor placement but also uses more network resources... update: in my testing reducing debounce timeout to 10ms doesn't make the cursor update method called significantly more. I think it is best to reduce the debounce timeout. |
Hey @sferoze, thank you for the comments. I've been a bit low on time in the latest few days, but let me catch this up and I'll get back to you. 👍 |
A known issue of this approach/example is a racing condition which makes cursors stuck/out-of-correct-position sometimes when a
selection-change
cursor update (which goes through cursors socket) is quickly followed by some edits (which goes through ShareDB and its socket) - like using the back arrow key with Ctrl to go to the beginning of a word and immediately start typing.How to replicate:
My take is that:
One solution for this was if... cursor updates could be transmitted through ShareDB (probably as ephemeral metadata like stated on share/sharedb#128).
Still needs more testing.
The text was updated successfully, but these errors were encountered: