Skip to content

Commit a1b72f7

Browse files
committed
Now handling case where span has same lo and hi.
1 parent 2161c3f commit a1b72f7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/libsyntax/codemap.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ impl CodeMap {
637637
/// Finds the width of a character, either before or after the provided span.
638638
fn find_width_of_character_at_span(&self, sp: Span, forwards: bool) -> u32 {
639639
// Disregard malformed spans and assume a one-byte wide character.
640-
if sp.lo() > sp.hi() {
640+
if sp.lo() >= sp.hi() {
641641
return 1;
642642
}
643643

@@ -671,11 +671,16 @@ impl CodeMap {
671671
} else {
672672
return 1;
673673
};
674+
debug!("DTW start {:?} end {:?}", start_index, end_index);
675+
debug!("DTW snippet {:?}", snippet);
674676

675677
let mut target = if forwards { end_index + 1 } else { end_index - 1 };
678+
debug!("DTW initial target {:?}", target);
676679
while !snippet.is_char_boundary(target - start_index) {
677680
target = if forwards { target + 1 } else { target - 1 };
681+
debug!("DTW update target {:?}", target);
678682
}
683+
debug!("DTW final target {:?}", target);
679684

680685
if forwards {
681686
(target - end_index) as u32

0 commit comments

Comments
 (0)