Skip to content

[Bug] Tree mode ignores -n and --limit #336

Description

@equationzhao

Describe the bug
-n 2 limits normal listing output to two entries. In tree mode, the same limit is ignored and all entries are printed.

To Reproduce

  1. Build the current repository:
go build -o /tmp/g-bug-audit .
  1. Create three files:
tmp=$(mktemp -d)
touch "$tmp/a" "$tmp/b" "$tmp/c"
  1. Run tree mode with a limit:
/tmp/g-bug-audit --no-config --disable-index --classic -A -T -n 2 "$tmp"
printf 'exit=%s tmp=%s\n' $? "$tmp"
  1. Actual output:
�[2m�[0mtmp.iWrYpNVtid
�[2m├── �[0ma
�[2m├── �[0mb
�[2m╰── �[0mc
exit=0 tmp=/var/folders/1b/57vdxmgj7s1glqm6tbsw1frm0000gn/T/tmp.iWrYpNVtid
  1. Control check with normal listing:
/tmp/g-bug-audit --no-config --disable-index --classic -A --byline -n 2 "$tmp"

Actual control output:

a
b
exit=0 tmp=/var/folders/1b/57vdxmgj7s1glqm6tbsw1frm0000gn/T/tmp.AEO3T7hoWn
  1. Expected output: tree mode should either honor -n 2 consistently or reject the combination with an explicit error.

Screenshots
Not applicable.

Info (please complete the following information):

  • OS: macOS darwin/arm64
  • Version: v0.31.2, Go go1.26.1

Additional context
The limit appears to be applied only when tree mode is not active, so tree mode silently ignores a user-specified limit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions