yjs / y-quill

Quill Editor binding for Yjs
https://demos.yjs.dev/quill/quill.html
MIT License
80 stars 18 forks source link

Jumping cursor #13

Closed volser closed 2 years ago

volser commented 2 years ago

If type text at the end of the line and there is a next line, the remote cursor is jumping to the next line.

how it looks: https://www.loom.com/share/c4a6206629dc49c6bc45bef548e2f9c3

dmonad commented 2 years ago

I'm not sure if we can fix that - seems to be an issue with the quill-cursors package.

Closing, but let me know if you have an idea on how to fix this.

volser commented 2 years ago

@dmonad it does not looks like quill-cursors package bug

yjs calls this line twice successively one by one with different index https://github.com/yjs/y-quill/blob/master/src/y-quill.js#L44

volser commented 2 years ago

@dmonad it calls move cursor 3 times on type 1 symbol. So how issue could be in quill-cursors lib?

image

only last update is correct. It sends an Awareness update before content update is applied.

Cursor updates:

  1. Awareness update (this one is wrong and cursor jumps here)
  2. Content update (cursor already in wrong position)
  3. Awareness update (this update fixes position)

image

volser commented 2 years ago

@dmonad do you know Quill's editor-change emits 2 different events (text-change and selection-change). So if you type symbol it emits 2 events and first is selection-change and only then text-change. Can it be root of the issue?