Skip to content

Commit 37da5a0

Browse files
committed
Fix add_magnitude_separators
1 parent 5985ec8 commit 37da5a0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

common/src/format.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,12 @@ impl FormatSpec {
436436
let sep = char::from(fg);
437437
let inter = self.get_separator_interval().try_into().unwrap();
438438
let magnitude_len = magnitude_str.len();
439-
let width = self.width.unwrap_or(magnitude_len) as i32 - prefix.len() as i32;
440-
let disp_digit_cnt = cmp::max(width, magnitude_len as i32);
439+
let disp_digit_cnt = if let Some('0') = self.fill.and_then(|p| p.to_char()) {
440+
let width = self.width.unwrap_or(magnitude_len) as i32 - prefix.len() as i32;
441+
cmp::max(width, magnitude_len as i32)
442+
} else {
443+
magnitude_len as i32
444+
};
441445
Self::add_magnitude_separators_for_char(magnitude_str, inter, sep, disp_digit_cnt)
442446
}
443447
None => magnitude_str,

0 commit comments

Comments
 (0)