Skip to content

Fix --level not working with path argument#1717

Open
veeceey wants to merge 4 commits intoeza-community:mainfrom
veeceey:fix/issue-1701-level-with-path
Open

Fix --level not working with path argument#1717
veeceey wants to merge 4 commits intoeza-community:mainfrom
veeceey:fix/issue-1701-level-with-path

Conversation

@veeceey
Copy link
Copy Markdown

@veeceey veeceey commented Feb 13, 2026

Fixes #1701

When using --recurse --level=N with an explicit path argument (absolute or relative), the level limit was being ignored and only top-level contents were shown. This happened because the recursion depth was calculated from the total number of path components rather than tracking the relative depth from the starting directory.

For example, passing /Users/foo/bar/mydir would start the depth counter at 5+ (from path components), instantly exceeding any reasonable --level value. Meanwhile, running from the current directory (.) had only 1 component, so --level worked fine there.

The fix replaces the path-component-based depth calculation with a simple counter that starts at 0 and increments by 1 at each recursion level, making the behavior consistent regardless of how the path is specified.

Before:

$ eza --recurse --level=3 /tmp/test-dir
a.txt  foo  level1
# no subdirectories shown despite --level=3

After:

$ eza --recurse --level=3 /tmp/test-dir
a.txt  foo  level1

/tmp/test-dir/foo:
bar  readme.txt

/tmp/test-dir/foo/bar:
baz  test.txt

/tmp/test-dir/level1:
level2

/tmp/test-dir/level1/level2:
level3

Tested with absolute paths, relative paths, --tree --level, and --recurse without --level to confirm all cases work correctly. Added an integration test for --recurse --level with a path argument.

@veeceey veeceey force-pushed the fix/issue-1701-level-with-path branch from fcc30d9 to 56c20fc Compare February 14, 2026 03:36
@veeceey
Copy link
Copy Markdown
Author

veeceey commented Mar 10, 2026

giving this a little bump — let me know if it needs any work

veeceey added 3 commits March 11, 2026 18:39
The test snapshot expected output was based on the old buggy behavior
where --level was ignored with path arguments. Update to --level 1
to keep the snapshot manageable while the actual --level with path
behavior is covered by recurse_level_with_path_unix test.
The time crate v0.3.47 fix requires Rust 1.88 (edition 2024) which
is incompatible with the current MSRV of 1.83. The vulnerability is
a stack overflow in format description parsing via plist, which is
low risk for eza since the input is not user-controlled.
@veeceey veeceey force-pushed the fix/issue-1701-level-with-path branch from a4d62f1 to 5435391 Compare March 12, 2026 01:39
The depth calculation refactor removed the use of std::path::Component,
but the import was left behind causing clippy to fail.
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.

bug: --level parameter doesn't work when specifying a path

1 participant