Closed wnayes closed 3 weeks ago
Some recent patches (https://github.com/codemirror/view/commit/959a7e41c2a3bcb4b9b2a1082b6e952c1148b52c, https://github.com/codemirror/view/commit/55dcef8b159b4d22068cadd4ea38c4e9267fc10e, https://github.com/codemirror/view/commit/821b3a962a98e32f3b4dccde2e2bf9b5446a128c) should make this somewhat better. There's still a shift on the first click, but subsequent clicks around the same viewport don't cause further shifting.
Solving that first shift (caused by selection moving away from the start of the document, removing the need to render the first line, causing it to also be scaled down) would require some invasive code that I'm not sure the weight of the issue justifies.
Thanks for looking into this! I tried the latest @codemirror/view
release and it seems to address the problem. Maybe there is some first shift, but it doesn't seem consistent or really that noticeable.
Describe the issue
In very large documents, if I scroll to various positions in the middle of the document and click around, the scroll position / viewport shifts with each mouse down. It seems to do this until it reaches a "settling point" where it stops shifting on click, but then scrolling to another location and trying clicks again will usually "reset" and exhibit the problem again.
It is also noticeable that gutter line numbers seem to get out of sync while clicking.
Here is a video of what I'm seeing. I click around a few times, and then try to drag to select just a single line.
https://github.com/codemirror/dev/assets/1417866/b6f431e0-5438-4a65-8a08-d4fcf86ba8a5
This issue makes the editor very hard to use with large documents, as it is hard to accurately select text when the document scrolls while dragging the mouse.
Apologies if this is a known issue or a duplicate, but other issues I found didn't seem to exactly describe this issue.
1086 describes the scrollbar itself behaving unusually when it is dragged around.
415 describes select all (Ctrl+A) causing some shifting. (It seems like it "corrects" or settles the misalignment upon Ctrl+A.)
I observed that the scrolling shift seems to be coming from this
scrollTop
update, but I don't know much more than that. It seems like thediff
is always a few pixels.Browser and platform
Chrome (Windows), Firefox 126.0 (Linux)
Reproduction link
https://codemirror.net/examples/million/