Repository navigation
fix: render deeply nested trees without panicking at narrow widths - #655
Closed
qiyuhuating wants to merge 1 commit into
Closed
qiyuhuating wants to merge 1 commit into
qiyuhuating wants to merge 1 commit into
Conversation
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.
Fixes #654.
Problem
At 40 nested directories and 80 output columns, Dust's file-tree scan succeeds but rendering panics with
Terminal width not wide enough to draw directory tree(exit 101). The tree indentation alone can exceed the space available for names.Change
Only when the indentation would leave too little room for a name, collapse its leftmost visible portion with an ellipsis, retaining the nearby branches and reserving room for the filename. The full internal indentation remains unchanged for child traversal and bar-depth calculation. Ordinary names and wide-terminal output keep their existing rendering.
Reproduction and verification
On Ubuntu 24.04 (WSL), from
masterSHA079c552versus the proposed commit14df60c:dust --config empty.toml -P -c -w 80 -n 100 TREEon a 40-directory-deep tree with a leaf file: before panic / exit 101; after exit 0, 42 output lines, leaf included.cargo test --locked -q: 85 passed, 0 failed.cargo fmt --all -- --check: passed.cargo clippy --locked --bin dust -- -D warnings: passed.cargo clippy --locked --all-targets -- -D warningsstill reports pre-existingempty_line_after_doc_commentserrors in unmodifiedtests/test_exact_output.rsandtests/test_flags.rs. These are unrelated to this fix.AI assistance: ChatGPT assisted with implementation, regression design, and verification.