Keep the input filename in pager prompts - #3984
Open
Matei02355 wants to merge 2 commits into
Open
Conversation
Matei02355
marked this pull request as ready for review
September 7, 2026 15:53
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.
When bat sends highlighted input over a pipe, less cannot determine its original filename. Long files therefore lose their visible identity once the header scrolls away.
Pass a single input's display name to the pager. Standard less shows it in the short, medium, long and
=prompts, while the built-in pager uses it as its footer. Named stdin and library input titles work too. Multiple inputs retain the normal prompt. If the user opens a different file inside less, its actual name is displayed.Escape less prompt metacharacters and display control characters visibly. Pass prompt values as separate arguments so a dollar sign in a filename cannot introduce more less options. Explicit command-line prompts take precedence; potentially customized prompts in LESS are left alone. BusyBox and unknown pagers receive no filename options. The existing public OutputType::from_mode API remains available unchanged.
Fixes #1855.
Validation: 479 tests passed with all features and a single test thread, including six new process regressions; seven platform/manual tests were ignored. All-target/all-feature Clippy, formatting and the minimal regex-onig library build passed. Real PTY sessions with less 590 verified short/medium/long/
=views and an explicit custom prompt; a real built-in pager session also displayed the sanitized filename and exited normally. These checks included spaces, punctuation, backslashes, dollar signs, newline, tab and ESC in the display name. An initial parallel run hit an unrelated LESSOPEN test; its focused rerun and the complete serial suite passed.