-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Interpret precision as display width #4443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Please address inline comments and add a test case to format-test.cc
include/fmt/format.h
Outdated
|
||
template <typename Char> | ||
FMT_CONSTEXPR auto handle_precision( | ||
basic_string_view<Char> s, const Char* data, const format_specs& specs, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to separately pass data
- you can use s
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 03b6f3a
include/fmt/format.h
Outdated
FMT_ENABLE_IF(std::is_same<Char, char>::value)) -> size_t { | ||
auto code_points = count_code_points_with_display_width_precision( | ||
to_string_view(data), to_unsigned(specs.precision)); | ||
return code_point_index(s, to_unsigned(code_points)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code_points
is already unsigned
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in c573671
Added the test case for introduced function dd25ea9. |
Fixes #4272
It now correctly considers precision as display width precision.
Please let me know, if I need to add any test cases as well.
Thanks!