Skip to content

Commit f8c8294

Browse files
authored
Merge pull request #5741 from ytmimi/issue_5739
Properly handle unicode whitespace chars when rewriting missing spans
2 parents 0cf8543 + fd5e84f commit f8c8294

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/missed_spans.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ impl<'a> FmtVisitor<'a> {
206206
// 2: blank lines.
207207
self.push_vertical_spaces(newline_count);
208208
status.cur_line += newline_count;
209-
status.line_start = offset + lf_count + crlf_count * 2;
209+
// To avoid any issues with whitespace unicode chars just add the len of the slice
210+
status.line_start = offset + subslice.len()
210211
} else {
211212
// 3: code which we failed to format or which is not within file-lines range.
212213
self.process_missing_code(&mut status, snippet, subslice, offset, file_name);

tests/source/issue_5739.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Note the input snippet is: `compile-flags: -Z dump-mir-spanview=block\n\n\n\u{2029}\n`
2+
// compile-flags: -Z dump-mir-spanview=block
3+
4+
5+
6+

tests/target/issue_5739.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Note the input snippet is: `compile-flags: -Z dump-mir-spanview=block\n\n\n\u{2029}\n`
2+
// compile-flags: -Z dump-mir-spanview=block

0 commit comments

Comments
 (0)