Skip to content

Show a size that rounds up to 1024 in the next unit - #70

Merged
tobi merged 1 commit into
tobi:mainfrom
kevin9327:fix/size-rounds-into-next-unit
Oct 4, 2026
Merged

tobi merged 1 commit into
tobi:mainfrom
kevin9327:fix/size-rounds-into-next-unit

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

human_bytes only steps up a unit at 1024, but from 9.95 up it prints no decimal. So any size between 1023.5 and 1024 of a unit is shown as 1024 of that unit:

bytes before after
1,048,575 1024 KiB 1.0 MiB
1,073,741,823 1024 MiB 1.0 GiB
1,047,552 (1023 KiB) 1023 KiB 1023 KiB

human_count has the same problem at 1000: 999,999 files is shown as 1000.0k, and 999,999,999 as 1000.0M. Both now step up where the displayed number would round to the next unit (1023.5 for bytes, 999,950 and 999,950,000 for counts). The labels on tiles, the header and the review list all go through these two functions.

How I verified it:

  • New test a_value_that_rounds_up_to_the_next_unit_is_shown_in_it in size.rs. It fails on main (left: "1024 KiB", right: "1.0 MiB") and passes with this change. The existing size tests still pass.
  • cargo fmt --all --check and cargo clippy --all-targets -- -D warnings on disktree-core (toolchain 1.97): clean.
  • cargo test in disktree-core: 130 passed. Three removal trash tests fail the same way on unmodified main in my sandbox ("on a different filesystem than the trash"), so they aren't related to this change.
  • I didn't build disktree-app (no GPUI system libraries here). It only calls these functions; there's no signature change.

human_bytes steps up a unit only at 1024, but above 9.95 it prints no decimal, so anything from 1023.5 to 1024 of a unit rounded to "1024 KiB" instead of "1.0 MiB" (1,048,575 bytes, for one). human_count had the same edge at 1000: 999,999 files read "1000.0k". Both now step up where the shown number would round to the next unit.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@tobi
tobi merged commit f845666 into tobi:main Oct 4, 2026
6 checks passed
@tobi tobi mentioned this pull request Oct 4, 2026
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.

2 participants