Skip to content

fix: render deeply nested trees without panicking at narrow widths - #655

Closed
qiyuhuating wants to merge 1 commit into
bootandy:masterfrom
qiyuhuating:fix/narrow-deep-tree-render
Closed

qiyuhuating wants to merge 1 commit into
bootandy:masterfrom
qiyuhuating:fix/narrow-deep-tree-render

Conversation

@qiyuhuating

Copy link
Copy Markdown

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 master SHA 079c552 versus the proposed commit 14df60c:

  • dust --config empty.toml -P -c -w 80 -n 100 TREE on a 40-directory-deep tree with a leaf file: before panic / exit 101; after exit 0, 42 output lines, leaf included.
  • New regression covers 40 levels, both normal and reversed output, every node preserved and line width no more than 80 columns.
  • 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 warnings still reports pre-existing empty_line_after_doc_comments errors in unmodified tests/test_exact_output.rs and tests/test_flags.rs. These are unrelated to this fix.

AI assistance: ChatGPT assisted with implementation, regression design, and verification.

@bootandy bootandy closed this Nov 19, 2026
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.

Deep directory trees cause a rendering panic at narrow terminal widths

3 participants