Skip to content

🐞 Scrollbar twitches around when scrolling large file #184

Closed

Description

@Eliulm

Description

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

  1. Open file with content that does not fit in viewport.
  2. Scroll

Expected Behavior

Scrollbar animation should be smooth and self.textView.frame.height should stay constant during scrolling.

Version Information

CodeEditTextView: 0.6.2
macOS: 13.3.1
Xcode: 14.3

Additional Context

No response

Screenshots

Screen.Recording.2023-04-30.at.20.25.07.mov

Activity

  1. austincondiff commented on Apr 30, 2023

    @austincondiff
    Collaborator

    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.

  2. Eliulm commented on Apr 30, 2023

    @Eliulm
    ContributorAuthor

    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
  3. thecoolwinter commented on May 1, 2023

    @thecoolwinter
    Collaborator

    There's two issues happening here:

    • 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 STTextView here 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.
  4. austincondiff commented on May 1, 2023

    @austincondiff
    Collaborator

    @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?

  5. added a commit that references this issue on Dec 9, 2023
    40d8e88
  6. moved this from 🆕 New to 🏁 Complete in CodeEdit Projecton Dec 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions