Skip to content

Reserve prompt rows during automatic less paging - #3999

Open
Matei02355 wants to merge 2 commits into
sharkdp:masterfrom
Matei02355:automatic-paging-offset-1620-20260907
Open

Reserve prompt rows during automatic less paging#3999
Matei02355 wants to merge 2 commits into
sharkdp:masterfrom
Matei02355:automatic-paging-offset-1620-20260907

Conversation

@Matei02355

Copy link
Copy Markdown
Contributor

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.

@Matei02355
Matei02355 marked this pull request as ready for review September 7, 2026 18:28
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.

Option to set line number offset for automatic paging

1 participant