Skip to content

Underline existing literal file paths without replacing syntax colors - #3996

Open
Matei02355 wants to merge 2 commits into
sharkdp:masterfrom
Matei02355:mark-existing-paths-2907-20260907
Open

Underline existing literal file paths without replacing syntax colors#3996
Matei02355 wants to merge 2 commits into
sharkdp:masterfrom
Matei02355:mark-existing-paths-2907-20260907

Conversation

@Matei02355

Copy link
Copy Markdown
Contributor

Add --show-paths and PrettyPrinter::show_paths to underline recognizable literal paths that exist locally. This follows the issue author's proposed first iteration of checking existing paths only.

Resolve relative paths from each real input file's directory, or the working directory for stdin and custom readers. A display-only filename does not change that base. Recognize slash-separated paths, native Windows paths, leading ~/ and quoted filenames containing a dot; quoted paths may contain spaces. Ignore URLs and shell expressions, and leave missing or inaccessible paths unchanged.

Underline instead of replacing foreground colors, so existing escape/error colors and other font attributes remain visible. This checks literal path spellings, without decoding language escapes or claiming to validate configuration semantics. Cache checks separately for each input, retaining at most 4096 entries. Skip the filesystem work unless the option and colored output are enabled, and only inspect lines that will be displayed.

Validation: all 482 all-feature tests passed (7 ignored), including nine Linux regressions for per-file bases, display names, stdin, Unicode/space-containing paths, directories, missing paths, broken symlinks, URLs, unclosed quotes, home expansion, color suppression, library usage and preservation of existing styles. An additional Windows-only regression covers drive and backslash paths. All 8 default-feature help tests passed. All-target/all-feature Clippy with warnings denied, the minimal library build, formatting, whitespace checks and Bash/Zsh completion syntax passed. README, manual, help and all four completions are updated.

Fixes #2907.

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

Detect paths and highlight them if missing

1 participant