Skip to content

feat: Add scrollbar #131

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

feat: Add scrollbar #131

wants to merge 3 commits into from

Conversation

peso
Copy link
Contributor

@peso peso commented May 28, 2025

This PR adds scrollbars to windows that can scroll. This gives a visual indicator of how far you have scrolled.

@peso peso force-pushed the add-scrollbar branch from 0220bb4 to 1eb008c Compare May 29, 2025 05:52
Copy link
Collaborator

@istudyatuni istudyatuni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, looks good, thanks! Will review soon™

@peso peso force-pushed the add-scrollbar branch from 1eb008c to 49a591d Compare May 29, 2025 15:03
Copy link
Collaborator

@istudyatuni istudyatuni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored scrollbar widget a bit. Also I think single line for scrollbar track is better than double in this case

@istudyatuni
Copy link
Collaborator

I rephrased comment a bit and removed todo: minus 1 comments, as I understand, -1 is not needed because we passing count of elements, and Scrollbar widget handle it

@istudyatuni
Copy link
Collaborator

@Cretezy could you enable rebase merge? I don't want to loose commit history

@peso peso force-pushed the add-scrollbar branch from 826670d to 32d9d23 Compare June 3, 2025 21:04
@peso
Copy link
Contributor Author

peso commented Jun 3, 2025

The TODO note was because I forgot why I did a -1 in the first place, but I rediscovered during testing:
The thumb cannot reach the bottom unless content_length is equal to the largest possible scroll-position. (So "Maximum" would have been a better term ;-) )
I included your comment rephrasing in the last push.

@istudyatuni
Copy link
Collaborator

istudyatuni commented Jun 3, 2025

When I tested it, it worked well, reaching the bottom just fine when the cursor was at the last element (didn't test your last change)

@peso
Copy link
Contributor Author

peso commented Jun 5, 2025

Apparently the scroll offset bug is a known problem: ratatui/ratatui#1681
Should I remove the -1 for now, file a bug on lazyjj, answer it myself with a reference to the ratatui issue?
I will also make a PR to ratatui, so this is just to get the current PR completed.

@peso
Copy link
Contributor Author

peso commented Jun 5, 2025

It seems like the terminal height affects the thumb position.

Example

Example with scroll not reaching bottom
image
Example where it does
image

@peso peso force-pushed the add-scrollbar branch from 32d9d23 to 16d0593 Compare June 5, 2025 11:09
@istudyatuni
Copy link
Collaborator

file a bug on lazyjj

I think we can ignore it, since this problem is rare. When this issue will be fixed in ratatui, we will just get fix with an update


Also, about splitting to logical commits:

  1. Some changes which should be in "refactor: Improve api of DetailsPanel" are in "feat: Scroll bars ..." commits
  2. Maybe collapse all "feat: Scroll bars ..." commits into one?

@peso
Copy link
Contributor Author

peso commented Jun 6, 2025

I see your point on DetailsPanel api. I guess I'm still learning when is the best time to use "jj absorb". I will move these changes.

Given that this further simplifies the "feat Scroll bar" commits, I can see your point on merging them. I will merge these 4 changes into 1.

@peso peso force-pushed the add-scrollbar branch from 16d0593 to 9b0d6a2 Compare June 6, 2025 18:31
@peso
Copy link
Contributor Author

peso commented Jun 12, 2025

This should be ready to merge. @Cretezy, are there any more things I need to do?

@istudyatuni
Copy link
Collaborator

I can merge too, I just want to do "rebase" merge, not "squash"

@dotdash
Copy link
Collaborator

dotdash commented Jun 17, 2025

If we don't want to wait, and you want to keep the individual commits (I'd want to, too), the slightly annoying approach would be to create individual PRs for them. 🤷🏻

@peso
Copy link
Contributor Author

peso commented Jun 17, 2025

Lets be pragmatic. I'd much prefer the individual commits but if the project prefers squashing PR then so be it. The other approach feels like working around the intention of project management. I will prefer good social relations over individual commits any day.

peso added 3 commits July 7, 2025 06:16
Instead of relying on access to DetailsPanel.scroll,
provide a setter function.
The scrollbar is used automatically, and less boilerplate code
is needed for drawing in all the tabs.
@peso peso force-pushed the add-scrollbar branch from 8d90a0d to a807c41 Compare July 7, 2025 04:16
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

Successfully merging this pull request may close these issues.

3 participants