Skip to content

Conversation

dundee
Copy link
Owner

@dundee dundee commented May 27, 2025

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.
Copy link

codecov bot commented May 27, 2025

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
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