Conversation
Co-authored-by: KSXGitHub <11488886+KSXGitHub@users.noreply.github.com>
--color=auto|always|never flag with LS_COLORS-aware file coloring
--color=auto|always|never flag with LS_COLORS-aware file coloring--color
Performance Regression Reportscommit: 5f4ca71 There are no regressions. |
…ify rendering Co-authored-by: KSXGitHub <11488886+KSXGitHub@users.noreply.github.com>
…, update docs Co-authored-by: KSXGitHub <11488886+KSXGitHub@users.noreply.github.com>
… remove redundant attributes Co-authored-by: KSXGitHub <11488886+KSXGitHub@users.noreply.github.com>
…structure TreeHorizontalSlice Co-authored-by: KSXGitHub <11488886+KSXGitHub@users.noreply.github.com>
Co-authored-by: KSXGitHub <11488886+KSXGitHub@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 26 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| let coloring: Option<Coloring> = color.map(|ls_colors| { | ||
| let mut map = HashMap::new(); |
There was a problem hiding this comment.
When pdu is run with multiple path arguments (e.g., pdu path1 path2), the code inserts a synthetic root node whose name is later changed from "" to "(total)" at line 147, before build_coloring_map is called at line 203. As a result, build_coloring_map constructs paths such as (total)/path1/file.txt and calls file_color on them. Since (total)/path1/file.txt does not exist on the filesystem, is_symlink(), is_dir(), and is_executable() all return false, and every file gets the default Color::Normal color — ignoring the actual file type. Symlinks and directories will be miscolored (shown as normal files) whenever --color is used with multiple path arguments. A fix would be to reconstruct each file's actual path from the child sub-trees before calling file_color, or to build the coloring map for each sub-tree individually using its original root path.
| let mut map = HashMap::new(); | |
| let mut map = HashMap::new(); | |
| // NOTE: When `pdu` is invoked with multiple path arguments, a synthetic | |
| // root node (renamed to "(total)") is created. Calling `build_coloring_map` | |
| // on that synthetic root can lead to non-existent filesystem paths like | |
| // "(total)/path1/file.txt" being passed to `file_color`, which in turn | |
| // causes all filesystem-type checks (is_dir, is_symlink, etc.) to fail and | |
| // results in incorrect coloring. The intended behavior is to build the | |
| // coloring map per real subtree (each original argument) so that only | |
| // actual filesystem paths are used for type detection. | |
| // | |
| // For now, we keep the single-root behavior here; special handling for | |
| // synthetic aggregate roots should be implemented inside `build_coloring_map` | |
| // (by skipping synthetic roots and traversing their children individually). |
Fixes #11.
Closes khai-slop-labs#1.
Adds
--color [auto|always|never]support, coloring tree output using theLS_COLORSenvironment variable.New components
ColorWhenenum (src/args/color.rs) —Auto(default, TTY-detect) /Always/NeverLsColors(src/ls_colors.rs) — wraps thelscolorscrate; parsesLS_COLORSinto per-indicator ANSI prefix strings forDirectory,Normal,Executable,SymlinkColor+Coloring(src/visualizer/coloring.rs) —Coloringholds aHashMap<PathBuf, Color>(full-path keys) and theLsColorsprefixes;node_color(&Path, has_children)drives per-node color selectionIntegration
Visualizergainscoloring: Option<&'a Coloring>;rows()wraps names in ANSI prefix/reset when setbuild_coloring_mapinsub.rswalks theDataTree, classifying leaves asSymlink > Directory > Executable (Unix) > Normal; directory coloring for internal nodes is resolved in the visualizer viahas_childrenApp::run()evaluates TTY state +ColorWhento construct and threadColoringthrough to the visualizer🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.