Fix the bug of next_point in span
This commit is contained in:
parent
11432fe952
commit
0af255a5aa
7 changed files with 13 additions and 13 deletions
|
@ -859,14 +859,15 @@ impl SourceMap {
|
|||
}
|
||||
let start_of_next_point = sp.hi().0;
|
||||
|
||||
let width = self.find_width_of_character_at_span(sp.shrink_to_hi(), true);
|
||||
let width = self.find_width_of_character_at_span(sp, true);
|
||||
debug_assert!(width > 0);
|
||||
// If the width is 1, then the next span should point to the same `lo` and `hi`. However,
|
||||
// in the case of a multibyte character, where the width != 1, the next span should
|
||||
// span multiple bytes to include the whole character.
|
||||
let end_of_next_point =
|
||||
start_of_next_point.checked_add(width - 1).unwrap_or(start_of_next_point);
|
||||
start_of_next_point.checked_add(width).unwrap_or(start_of_next_point);
|
||||
|
||||
let end_of_next_point = BytePos(cmp::max(sp.lo().0 + 1, end_of_next_point));
|
||||
let end_of_next_point = BytePos(cmp::max(start_of_next_point + 1, end_of_next_point));
|
||||
Span::new(BytePos(start_of_next_point), end_of_next_point, sp.ctxt(), None)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue