fix: item count for --show-item-count#416
Merged
Merged
Conversation
…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 ReportAll modified and coverable lines are covered by tests ✅
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. 🚀 New features to boost your workflow:
|
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a fix for issue #412 where
gdu --show-item-countincorrectly includes the directory itself in its item count.