You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears that panic happens in utils::trim_newlines function at &input[start..end] line because of improperly calculated let end = input.rfind(|c| c != '\n' && c != '\r').unwrap_or(0) + 1;. Obviously, + 1 part won't work in case of unicode symbols which spans over several bytes.
I've tried to fix the problem, but don't know how to get the width of character at given offset in &str using stable rust features. When unicode-rs/unicode-segmentation#21 will be resolved it would be possible to use GraphemeCursor for that purpose.
To test if proper addend resolves the issue i've used this hacky solution:
let end = input.rfind(|c| c != '\n' && c != '\r').unwrap_or(0);let rest = ::std::str::from_utf8(&input.as_bytes()[end..]).unwrap();let char_len = rest.chars().next().unwrap().len_utf8();let end = end + char_len;
and it did help.
The text was updated successfully, but these errors were encountered:
rustfmt panics on a codebase with multibyte characters in certain situations. Here is a backtrace
It appears that panic happens in
utils::trim_newlines
function at&input[start..end]
line because of improperly calculatedlet end = input.rfind(|c| c != '\n' && c != '\r').unwrap_or(0) + 1;
. Obviously,+ 1
part won't work in case of unicode symbols which spans over several bytes.I've tried to fix the problem, but don't know how to get the width of character at given offset in
&str
using stable rust features. When unicode-rs/unicode-segmentation#21 will be resolved it would be possible to useGraphemeCursor
for that purpose.To test if proper addend resolves the issue i've used this hacky solution:
and it did help.
The text was updated successfully, but these errors were encountered: