Reserve prompt rows during automatic less paging - #3999
Open
Matei02355 wants to merge 2 commits into
Open
Conversation
Matei02355
marked this pull request as ready for review
September 7, 2026 18:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add --paging-reserve=N and PrettyPrinter::paging_reserve to reserve terminal rows for a multiline shell prompt during automatic paging. This implements the prompt-reservation use case in #1620; negative offsets remain outside this option's scope.
Use less's LESS_LINES support, available in stable releases from 632 onward, to reduce both its viewport and its one-screen threshold. Ordinary reservations follow less's resize handling; a reservation that already fills the terminal leaves one row. Set the variable only for the child pager, overriding inherited LESS_LINES. Preserve forced and disabled paging, support repeated options, and apply automatic exit to custom less arguments. Unsupported pagers and older less versions report an actionable error when a reservation would be used.
Keep OutputType::from_mode compatible and add a separate constructor accepting the reservation. Wire the setting through normal output and theme previews. Document the viewport tradeoff in help, README and the manual; update all four completions.
Validation: all 478 all-feature tests passed (7 ignored), including new checks for argument validation, repeated settings, child pager configuration, old/unrecognized versions and forced-paging behavior. All 8 default-feature help tests, all-target/all-feature Clippy with warnings denied, the minimal library build, formatting, whitespace checks and Bash/Zsh completion syntax passed. Twelve real PTY checks against less 668 verified the automatic threshold, short output, disabled/forced paging, visible ranges, wrapped rows, custom arguments, oversized reservations and unsupported pagers. The standalone PTY regression script is included.
Fixes #1620.