Skip to content

Fix recursion output indentation and spacing#1202

Open
Shonas301 wants to merge 1 commit intolsd-rs:mainfrom
Shonas301:pr/recursion-indent
Open

Fix recursion output indentation and spacing#1202
Shonas301 wants to merge 1 commit intolsd-rs:mainfrom
Shonas301:pr/recursion-indent

Conversation

@Shonas301
Copy link
Copy Markdown

I've been using lsd -R for deep walks and it's hard to follow — entries sit
flush-left regardless of depth, and there are multiple blank lines between
subdirectory blocks. No visual nesting at all.

Changes:

  • indent each recursive entry by 2 * depth spaces (both headers and content)
    so the nesting reads visually
  • collapse runs of blank lines between directory blocks down to a single separator
  • tests covering per-depth indent at depth 1 and 2, plus a no-double-blank invariant

Before:

subdir:
file.rs

subdir/nested:


deep.rs

After:

  subdir:
    file.rs

    subdir/nested:
      deep.rs

Display-layer only — nothing in traversal or meta collection changed.


TODO

  • Use cargo fmt
  • Add necessary tests
  • Update README (if applicable)
  • Update config sample file in doc/samples (if applicable)
  • Update icon sample file in doc/samples (if applicable)
  • Update color sample file in doc/samples (if applicable)
  • Update man page at lsd/doc/lsd.md (if applicable)

* Add depth indentation to lsd -R output

Changes made:
- add depth param to display_folder_path, indent header by (depth+1)*2 spaces
- indent content lines by (depth+1)*2 spaces at depth > 0
- reduce available grid width by content indent to prevent overflow
- trim trailing newlines before section headers to remove double blank lines
- add tests: depth1 indent, depth2 indent, no double blank lines

* Fix grid width reduction to only apply at depth > 0

Changes made:
- only subtract content_indent from term_width when depth > 0 (content is actually indented)
- depth 0 content uses full terminal width as before

* Simplify indent logic and reduce allocations

Changes made:
- add INDENT_STEP constant to replace magic number 2
- move content_prefix allocation behind depth > 0 guard
- single-pass fold replaces Vec + join for line indentation
- move +1 offset into display_folder_path for consistent API
- collapse trimmed_len intermediate variable
- remove redundant arithmetic comments from tests
@Shonas301
Copy link
Copy Markdown
Author

image

Sorry about the cold open of this and #1203 ! screen shot is attached for what it looks like! If there are changes requested just lmk, nbd, if you don't think it belongs in the upstream just lmk.

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.

1 participant