Fix handling of # in width computation
This commit is contained in:
parent
061e364b25
commit
0fe0b15e71
@ -1925,7 +1925,7 @@ OutputIt write_float(OutputIt out, const DecimalFP& fp,
|
||||
#endif
|
||||
if (fspecs.showpoint) {
|
||||
if (num_zeros <= 0 && fspecs.format != float_format::fixed) num_zeros = 1;
|
||||
if (num_zeros > 0) size += to_unsigned(num_zeros);
|
||||
if (num_zeros > 0) size += to_unsigned(num_zeros) + 1;
|
||||
}
|
||||
return write_padded<align::right>(out, specs, size, [&](iterator it) {
|
||||
if (sign) *it++ = static_cast<Char>(data::signs[sign]);
|
||||
|
@ -869,6 +869,7 @@ TEST(FormatterTest, Width) {
|
||||
EXPECT_EQ("x ", format("{0:11}", 'x'));
|
||||
EXPECT_EQ("str ", format("{0:12}", "str"));
|
||||
EXPECT_EQ(fmt::format("{:*^5}", "🤡"), "**🤡**");
|
||||
EXPECT_EQ(fmt::format("{:#6}", 42.0), " 42.0");
|
||||
}
|
||||
|
||||
template <typename T> inline T const_check(T value) { return value; }
|
||||
|
Loading…
Reference in New Issue
Block a user