Repository navigation
fix: flat layout sort order and spacing - #11
Merged
Merged
Conversation
Flat layouts walked the per-directory-sorted hierarchy, so --sort (and --dirs-only) produced an order that only made sense for a tree. Sort all entries globally for flat/iflat via Tree::flat_order (root pinned last/first) and drop the per-hierarchy walk. When the size column is empty (--suppress-size), omit it and its separator instead of printing a blank column with leading whitespace. Fixes solidiquis#224, solidiquis#241. Based on the approach in solidiquis#234. Co-authored-by: siqpush <98565842+siqpush@users.noreply.github.com>
jeiang
enabled auto-merge
October 14, 2026 14:30
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 upstream solidiquis#224 and solidiquis#241.
Sorting (solidiquis#224). Flat/iflat output walked the tree that was sorted per directory, so with e.g.
--sort size --dirs-onlya nested dir smaller than its parent's sibling appeared out of order. Evaluated upstream PR solidiquis#234: it re-parents all nodes to the root during assembly and re-sorts, but its updated test expectations are not actually sorted and it drops ordering of parents vs. children; I instead addedTree::flat_order, which globally stable-sorts all non-root nodes (by--sort/--dir-order) over a pre-order walk, root pinned first (iflat) / last (flat, which is the reverse). Ties list a directory before its contents. Regular/inverted layouts are untouched. Author credited via Co-authored-by.Whitespace (solidiquis#241). An empty size cell (
--suppress-size, or no sizes) no longer emits a blank column; the row is just the path. Spacing otherwise unchanged (3 spaces after the size).Changed expectations:
flatandflat_humanintests/flat.rsencoded the hierarchical (per-directory) order, which is the bug; they now show the global order.Tests: new
tests/flat_datafixture + tests for flat/iflat dirs-only and files+dirs size ordering and a whitespace test (run_cmd_untrimmedadded becauserun_cmdtrims). All fail before the fix.Before (
erd --layout flat --sort size --dirs-only tests/flat_data):50 b, 40 a/c, 60 a, 110 flat_data; after:40 a/c, 50 b, 60 a, 110 flat_data.--suppress-size: rows werepath(3 leading spaces), nowpath.