File tree 1 file changed +4
-6
lines changed
1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -598,18 +598,16 @@ impl CodeMap {
598
598
/// If `sp` points to `"let mut x"`, then a span pointing at `"let "` will be returned.
599
599
pub fn span_until_non_whitespace ( & self , sp : Span ) -> Span {
600
600
if let Ok ( snippet) = self . span_to_snippet ( sp) {
601
- let mut offset = 0 ;
602
- let mut pos = 0 ;
601
+ let mut offset = 1 ;
603
602
// get the bytes width of all the non-whitespace characters
604
- for ( i , c ) in snippet. chars ( ) . take_while ( |c| !c. is_whitespace ( ) ) . enumerate ( ) {
603
+ for c in snippet. chars ( ) . take_while ( |c| !c. is_whitespace ( ) ) {
605
604
offset += c. len_utf8 ( ) ;
606
- pos = i + 1 ;
607
605
}
608
606
// get the bytes width of all the whitespace characters after that
609
- for c in snippet[ pos ..] . chars ( ) . take_while ( |c| c. is_whitespace ( ) ) {
607
+ for c in snippet[ offset ..] . chars ( ) . take_while ( |c| c. is_whitespace ( ) ) {
610
608
offset += c. len_utf8 ( ) ;
611
609
}
612
- if offset != 0 {
610
+ if offset > 1 {
613
611
return sp. with_hi ( BytePos ( sp. lo ( ) . 0 + offset as u32 ) ) ;
614
612
}
615
613
}
You can’t perform that action at this time.
0 commit comments