Skip to content
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

Scroll position shifts on click into the middle of a large document #1384

Closed
wnayes opened this issue May 24, 2024 · 2 comments
Closed

Scroll position shifts on click into the middle of a large document #1384

wnayes opened this issue May 24, 2024 · 2 comments

Comments

@wnayes
Copy link

wnayes commented May 24, 2024

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.

codemirror_shifting.mp4

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.


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 the diff is always a few pixels.

Browser and platform

Chrome (Windows), Firefox 126.0 (Linux)

Reproduction link

https://codemirror.net/examples/million/

@marijnh
Copy link
Member

marijnh commented Jun 1, 2024

Some recent patches (codemirror/view@959a7e4, codemirror/view@55dcef8, codemirror/view@821b3a9) 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.

@wnayes
Copy link
Author

wnayes commented Jun 10, 2024

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.

@wnayes wnayes closed this as completed Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants