Skip to content

fix(blame): correct scrollbar max so thumb reaches bottom at last line#2975

Open
Noethix55555 wants to merge 1 commit into
gitui-org:masterfrom
Noethix55555:fix/gu-ui2-blame-scrollbar
Open

fix(blame): correct scrollbar max so thumb reaches bottom at last line#2975
Noethix55555 wants to merge 1 commit into
gitui-org:masterfrom
Noethix55555:fix/gu-ui2-blame-scrollbar

Conversation

@Noethix55555

Copy link
Copy Markdown

Summary

The draw_scrollbar call in BlameFilePopup::draw has used a stale workaround since April 2021, when tui-rs internally subtracted area.height from the max parameter before computing the thumb position. That subtraction was never part of our own draw_scrollbar (in src/ui/scrollbar.rs), so passing number_of_rows + area.height as max inflates it artificially.

Effect: The scrollbar thumb never reaches the bottom. For a 100-line file displayed in a 30-row terminal, the furthest the thumb travels is 99 / 130 ≈ 76% — even when the cursor is on the last line.

Fix: Pass number_of_rows.saturating_sub(1) as max, matching the pattern used by taglist and fuzzy_find (which pass len.saturating_sub(1) and work correctly). Remove the now-obsolete comments.

Test plan

  • Open blame on a file with more lines than the terminal height
  • Scroll to the last line with End
  • Confirm the scrollbar thumb is now at the bottom of the scrollbar track

The draw_scrollbar call used a stale workaround from April 2021 when
tui-rs subtracted area.height internally; that subtraction no longer
exists in draw_scrollbar, so passing number_of_rows + area.height as
the max inflated it artificially. At the last row the thumb reached at
most ~76% of the scrollbar height (for a 100-line file in a 30-row
terminal). Use number_of_rows.saturating_sub(1) -- the last valid
selection index -- matching the pattern used by taglist and fuzzy_find.
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.

1 participant