Skip to content

feat: implement lazygit-compatible scrollbars in list views - #42

Merged
Blankeos merged 1 commit into
Blankeos:mainfrom
felipecm-br:feat/scrollbar-parity
Nov 5, 2026
Merged

Blankeos merged 1 commit into
Blankeos:mainfrom
felipecm-br:feat/scrollbar-parity

Conversation

@felipecm-br

Copy link
Copy Markdown
Contributor

Description

Implements exact lazygit-compatible vertical scrollbar rendering logic across all scrollable list views and diffs.

Details

  • Ported calcScrollbar, calcScrollbarHeight, and calcRealScrollbarStartEnd from lazygit (pkg/gocui/scrollbar.go and gui.go).
  • Renders the vertical scroll indicator using ▐ (Right Half Block) on the right panel border with matching theme border styling.
  • Integrates into list views (render_list_with_range and render_list_with_range_raw) and side-by-side / unified diff views.
  • Comprehensive unit tests matching lazygit's scrollbar_test.go verifying thumb height, scroll range, and boundary conditions.

Validation

  • cargo test --bin lazygitrs (all 378 tests passed)
  • cargo fmt --check

@felipecm-br

Copy link
Copy Markdown
Contributor Author
image

This is how the scroll looks like :)

@Blankeos

Blankeos commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

feat/scrollbar-parity → main
Model: claude-sonnet-5-5, effort unknown

Confidence: 4.5/5

Checks run: cargo fmt --check clean; cargo test on the branch: 378 passed, 0 failed (includes the 4 new scroll tests, the 2 list-panel tests and the diff-border test). Built it for Linux and ran it in a temp repo with 61 commits, 41 changed files and a 200-line diff: the ▐ thumb appears on the right border of the Files and Commits lists, tracks the scroll position (top when the selection is in view, bottom at the end of the list), is hidden when the content fits (Status/Branches/Stash), and shows in the side-by-side diff view when scrolled. cargo clippy flags one collapsible if in scroll.rs:133.
Confidence bumps: none left that I can do. Not covered: image diffs and very narrow terminals (not exercised); fix the clippy nit and it is 5/5.

Summary

Thanks Felipe, this is a clean port. calc_scrollbar, calc_scrollbar_height and calc_real_scrollbar_start_end follow lazygit, and the test table mirrors scrollbar_test.go. The ▐ thumb is drawn on the right border for the commit list, the generic lists, commit details and the diff view. A few small things:

  • The thumb colour in commit_details.rs is hard-coded to theme.inactive_border. That's probably right because the panel isn't focusable, but it's worth a quick check.
  • In side_by_side.rs the scrollbar is drawn just before render_inline_image_regions. Please confirm that image diffs and empty diffs look right, since the border column could be touched in those paths.
  • The commit details total_rows is an estimate based on chars().count(), so wide or CJK text can make the thumb size slightly off. Fine for now.
  • The two view tests call the private render_list_with_range_raw directly, which is fine. Consider one test with is_active=false to cover the colour choice.
    Otherwise looks good to me.

Map

flowchart LR
  scroll[gui/scroll.rs: calc_scrollbar + render_scrollbar]
  views[gui/views.rs: render_list_with_range_raw]
  commits[gui/views.rs: render_commit_list_ctx]
  details[presentation/commit_details.rs]
  diff[pager/side_by_side.rs: render_diff]
  views --> scroll
  commits --> scroll
  details --> scroll
  diff --> scroll
Loading

Start at src/gui/scroll.rs; the other three files are one call each.

Regressions

  • Render-only. Writes one cell (▐) per thumb row on the right border column, so no state or input behaviour changes.
  • The diff view passes can_scroll_past_bottom = true, which matches max_scroll() = total_rows - 1 on main, so the thumb math is consistent.
  • Early-return paths (empty list, visible_height == 0) skip the scrollbar, which is correct.
  • top_y + start as u16 can overflow u16 only with absurd sizes. Not realistic.
  • Visual change: every scrollable panel now shows a thumb on its border. Users who don't want it have no toggle, which is the same as lazygit.
  • Merge-conflict risk: feat(gui): 60 FPS draggable sidebar divider with visual hover indicator #48 also edits src/gui/views.rs, and this PR touches render_commit_list_ctx and render_list_with_range_raw there. feat(gui): 60 FPS draggable sidebar divider with visual hover indicator #48 changes the render signature, so the conflict is likely small. No other open PR touches these files.

Migrations

None. No config, keybinding or format changes.

Before merging

@Blankeos

Blankeos commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Ran this build in Ghostty on a repo with ~160 changed files. The ▐ thumb shows on the right edge of the Files list and tracks the scroll position.

Scrollbar thumb on the Files list

@Blankeos
Blankeos merged commit 7396388 into Blankeos:main Nov 5, 2026
6 checks passed
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.

2 participants