Skip to content

fix(pager): G/End overshoot makes k/Up unresponsive after jump to bottom#1706

Closed
wlon wants to merge 2 commits into
Hmbown:mainfrom
wlon:fix/pager-g-scroll-overshoot
Closed

fix(pager): G/End overshoot makes k/Up unresponsive after jump to bottom#1706
wlon wants to merge 2 commits into
Hmbown:mainfrom
wlon:fix/pager-g-scroll-overshoot

Conversation

@wlon

@wlon wlon commented May 16, 2026

Copy link
Copy Markdown

Summary

After pressing G or End to jump to the bottom of the pager (Ctrl+O reasoning list, tool detail, etc.), pressing k / Up to scroll back up had no visible effect for many consecutive presses.

Root cause

max_scroll() returned lines.len() - 1 while render() clamped to lines.len() - visible_height. The gap meant G set scroll far above the render clamp. Each k/Up press decremented scroll inside that overshoot gap, producing zero visible movement until the value finally fell below the clamp.

For a 50-line pager with ~18 visible lines, this required 17 consecutive k presses before any content scrolled up.

Fix

Changed max_scroll() to use page_height() (the cached visible_height from the last render), matching the render-side clamp:

// Before
self.lines.len().saturating_sub(1)
// After
self.lines.len().saturating_sub(self.page_height().max(1))

Tests

Two regression tests added. All 33 pager tests pass.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request modifies the max_scroll calculation in the TUI pager to prevent over-scrolling when jumping to the bottom, ensuring that subsequent scroll-up actions are immediately visible. It also adds unit tests to verify this behavior. A review comment suggests removing a redundant .max(1) call from the new calculation to simplify the code.

Comment thread crates/tui/src/tui/pager.rs Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@Hmbown Hmbown added this to the v0.8.39 milestone May 16, 2026
Hmbown added a commit that referenced this pull request May 17, 2026
Bump workspace, inter-crate, and npm package versions 0.8.38 -> 0.8.39.

Roll CHANGELOG [Unreleased] into [0.8.39] with all fixes:
- Revert v0.8.38 /model picker rework (back to instant curated picker)
- Restore approval grouping (lossy v0.8.37 logic for approvals, exact key for denials)
- Thinking-only turn surface fix (#1727)
- ACP server JSON-RPC id stringification (#1696)
- Chat client: reasoning_content for generic providers (#1673)
- Compaction: user text query preservation (#1704)
- Engine: system prompt override survival (#1688)
- Pager: G/End overshoot fix (#1706), mouse scroll (#1716)
- Composer: scroll with text (#1677), multiline arrows (#1721)
- macOS system theme detection (#1670)
- rlm_open blank source fields (#1712)
- Terminal resize paging fix (#1724)
- Docker first-run permission (#1684)
- README Rust 1.88+ requirement note (#1718)

Tests: 3149 passed, 0 failed (deepseek-tui crate)
clippy: clean on --all-targets --all-features
@Hmbown

Hmbown commented May 17, 2026

Copy link
Copy Markdown
Owner

Thanks for the clear pager repro. The G/End bottom clamp fix was harvested into v0.8.39 via #1734 and credited in the changelog, so I am closing this PR to keep the queue clean. Please reopen if v0.8.39 still needs multiple k/Up presses after jumping to the bottom.

@Hmbown Hmbown closed this May 17, 2026
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