Skip to content

Commit

Permalink
Handle non-ascii character at boundary
Browse files Browse the repository at this point in the history
  • Loading branch information
scampi committed Nov 17, 2021
1 parent eee8f04 commit 76d626f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ fn break_string(max_width: usize, trim_end: bool, line_end: &str, input: &[&str]
// Find the position in input for breaking the string
if line_end.is_empty()
&& trim_end
&& !is_whitespace(input[max_width_index_in_input - 1])
&& !is_whitespace(input[max_width_index_in_input.checked_sub(1).unwrap_or(0)])
&& is_whitespace(input[max_width_index_in_input])
{
// At a breaking point already
Expand Down
19 changes: 19 additions & 0 deletions tests/target/issue-5023.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// rustfmt-wrap_comments: true
fn main() {
if xxx {
let xxx = xxx
.into_iter()
.filter(|(xxx, xxx)| {
if let Some(x) = Some(1) {
// xxxxxxxxxxxxxxxxxx, xxxxxxxxxxxx, xxxxxxxxxxxxxxxxxxxx xxx xxxxxxx, xxxxx xxx
// xxxxxxxxxx. xxxxxxxxxxxxxxxx,xxxxxxxxxxxxxxxxx xxx xxxxxxx
// 是sdfadsdfxxxxxxxxx,sdfaxxxxxx_xxxxx_masdfaonxxx,
if false {
return true;
}
}
false
})
.collect();
}
}

0 comments on commit 76d626f

Please sign in to comment.