-
-
Notifications
You must be signed in to change notification settings - Fork 375
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
Measure loop while scrolling in a scaled editor #1341
Comments
Indeed, that shouldn't be directly comparing floats like that. Attached patch adds a margin of .005 in which it doesn't treat the value as changed. |
Would it make sense to check if the computed scale is |
Any scales close to 1 are already rounded to that in getScale, so I don't think this will be an issue. |
I missed that, thanks! |
@marijnh The issue is still there when you use the scrollPastEnd plugin |
FIX: Improve behavior of `scrollPastEnd` in a scaled editor. Issue codemirror/dev#1341
@gquittet Can you provide a reproduction script for that? I couldn't get it to happen even with I did notice that extension didn't work right in a scaled editor, though. See attached patch. |
Describe the issue
The editor seems to get stuck in measure loops when scrolling while scaled and the loop is forcefully stopped with the "Measure loop restarted more than 5 times" check.
The issue can be easily reproduced adding a
transform: scale(0.5);
to the parent element of the editor on a demo page like: https://codemirror.net/examples/million/ and observing the console while scrolling fast or holding the Page Up/Down keys.From what I can tell the issue is that
getBoundingClientRect()
returns slightly different values while scrolling (probably because of rounding errors in BlockGapWidget height) and the scale computed in https://github.com/codemirror/view/blob/4e355eab50de94ab315ed293729f5365841fe3c8/src/viewstate.ts#L258 is also different so measuring continues at https://github.com/codemirror/view/blob/4e355eab50de94ab315ed293729f5365841fe3c8/src/editorview.ts#L427Rounding the computed scale to 2 decimal places seems to prevent issue and should also remove the need for the other range checks in
getScale
.An alternative fix would be to round the gap height at https://github.com/codemirror/view/blob/4e355eab50de94ab315ed293729f5365841fe3c8/src/docview.ts#L488 to an integer.
Unfortunately I'm not familiar enough with the project to know if the loss in precision from these changes would cause other issues or if there's a more appropriate fix.
I can open a PR with any of these options if it helps.
Browser and platform
MacOS & Windows / Firefox & Chrome
Reproduction link
No response
The text was updated successfully, but these errors were encountered: