You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
🐞 Scrollbar twitches around when scrolling large file #184
When scrolling large files, the scrollbar twitches around the place. Only if the whole document has been completely viewed, the scrollbar will behave as expected.
Upon further investigation, I found that the textview.frame.height property changes a lot during scrolling. It might be the reason, why the scrollbar behaves weirdly.
To Reproduce
Open file with content that does not fit in viewport.
Scroll
Expected Behavior
Scrollbar animation should be smooth and self.textView.frame.height should stay constant during scrolling.
Not sure if this is related or not, but when the scroll reaches line 100, things shift to the right to account for the additional digit. We should account for maximum ruler width upon file open, not on scroll.
It seems like we do this for wrapped lines as well. My theory is that we assume all lines do not wrap. When we scroll to wrapped lines, this adds additional height to the overall scroll height and will adjust the scroll indicator to account for this additional height (again this is just a theory).
After watching your video, it seems like the indicator gets bigger then smaller then bigger then smaller, etc. I believe this is because the wrapped lines are scrolling out of view so it is again assumed that they will be the unwrapped height.
Edit: I can validate this theory by scrolling an wide window with no wrapped lines and a narrower window with wrapped lines.
Large window with no wrapped lines:
Screen.Recording.2023-04-30.at.2.04.27.PM.mp4
Smaller window with wrapped lines:
Screen.Recording.2023-04-30.at.2.04.42.PM.mp4
Notice the scroll indicator in the larger window with no wrapped lines remains consistently sized as I scroll down the page while the scroll indicator in the smaller window with wrapped lines does not.
The issue brought up by @Eliulm is due to the text view not correctly estimating it's own height initially. There's some code that attempts to do this in STTextViewhere which updates as you scroll, apparently causing the last text element in the document to adjust it's y value as the document is scrolled.
The ruler adjusting its width is due to the ruler view not counting lines until it comes across them, which was just a design decision by STTextView. Before it reaches the 100th line the ruler's width is determined by a 2-character width. Then when it loads the 3-character one it adjusts its width. This could be fixed with a pull request to STTextView, or it may be an opportunity to implement an in-house ruler view.
@thecoolwinter That makes a lot more sense. Well if it is any indication, when there is not enough text to fill the viewport, the view is vertically scrollable, the height is the viewport height plus the CodeEdit status bar height (which I want to say is a bottom edge inset. So maybe we are not taking edge insets into account?
Activity
austincondiff commentedon Apr 30, 2023
Not sure if this is related or not, but when the scroll reaches line 100, things shift to the right to account for the additional digit. We should account for maximum ruler width upon file open, not on scroll.
It seems like we do this for wrapped lines as well. My theory is that we assume all lines do not wrap. When we scroll to wrapped lines, this adds additional height to the overall scroll height and will adjust the scroll indicator to account for this additional height (again this is just a theory).
After watching your video, it seems like the indicator gets bigger then smaller then bigger then smaller, etc. I believe this is because the wrapped lines are scrolling out of view so it is again assumed that they will be the unwrapped height.
Edit: I can validate this theory by scrolling an wide window with no wrapped lines and a narrower window with wrapped lines.
Large window with no wrapped lines:
Screen.Recording.2023-04-30.at.2.04.27.PM.mp4
Smaller window with wrapped lines:
Screen.Recording.2023-04-30.at.2.04.42.PM.mp4
Notice the scroll indicator in the larger window with no wrapped lines remains consistently sized as I scroll down the page while the scroll indicator in the smaller window with wrapped lines does not.
Eliulm commentedon Apr 30, 2023
Interesting. However, I just tried this too, but I still get the twitching in a file without line wraps:
Screen.Recording.2023-04-30.at.21.31.09.mov
thecoolwinter commentedon May 1, 2023
There's two issues happening here:
STTextViewhere which updates as you scroll, apparently causing the last text element in the document to adjust it'syvalue as the document is scrolled.austincondiff commentedon May 1, 2023
@thecoolwinter That makes a lot more sense. Well if it is any indication, when there is not enough text to fill the viewport, the view is vertically scrollable, the height is the viewport height plus the CodeEdit status bar height (which I want to say is a bottom edge inset. So maybe we are not taking edge insets into account?
Custom Text View (#211)