Skip to content

fix: item count for --show-item-count#416

Merged
dundee merged 2 commits into
masterfrom
fix-issue-412-partial
May 27, 2025
Merged

fix: item count for --show-item-count#416
dundee merged 2 commits into
masterfrom
fix-issue-412-partial

Conversation

@dundee

@dundee dundee commented May 27, 2025

Copy link
Copy Markdown
Owner

This is a fix for issue #412 where gdu --show-item-count incorrectly includes the directory itself in its item count.

…adjusted

This is a partial fix for issue #412 where `gdu --show-item-count`
incorrectly includes the directory itself in its item count.

Changes made so far:
- I investigated the analyzer logic (`pkg/analyze/*`) and determined that
  `Dir.ItemCount` is intentionally inclusive of the directory itself due
  to internal uses (e.g., ignored directories).
- I shifted the fix to the TUI layer to adjust the count only for display
  purposes when `--show-item-count` is active.
- I modified `tui/format.go` in the `formatFileRow` function:
  - If `ui.showItemCount` is true and the item is a directory, the
    displayed item count for that row is now `item.GetItemCount() - 1`.
  - Files continue to display their item count as is (0).

Pending work:
- I will modify `tui/show.go` to adjust the total item count displayed in the
  footer similarly.
- I will re-add and adjust `TestItemCount` in `pkg/analyze/dir_test.go` to
  assert the corrected user-facing item counts.
- I will run all tests to ensure correctness.
@codecov

codecov Bot commented May 27, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.38%. Comparing base (b105795) to head (e463a8b).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #416      +/-   ##
==========================================
- Coverage   87.44%   87.38%   -0.06%     
==========================================
  Files          46       46              
  Lines        4395     4399       +4     
==========================================
+ Hits         3843     3844       +1     
- Misses        477      479       +2     
- Partials       75       76       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dundee dundee merged commit 22789af into master May 27, 2025
9 checks passed
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this pull request Dec 29, 2025
https://build.opensuse.org/request/show/1324629
by user jfkw + anag_factory
- Version 5.32.0
  * feat: Add --no-spawn-shell flag to disable shell access (gh#dundee/gdu#440)
  * feat: Add support showing size of absent git-annex'ed files (gh#dundee/gdu#404)
  * fix: ctrl_z corruption (gh#dundee/gdu#253) by (gh#dundee/gdu#406)
  * fix: item count for --show-item-count (gh#dundee/gdu#416)
  * fix: automatically run non-interactive when related flag set (gh#dundee/gdu #418) (forwarded request 1324602 from RN)
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