File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed
Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -598,18 +598,16 @@ impl CodeMap {
598598 /// If `sp` points to `"let mut x"`, then a span pointing at `"let "` will be returned.
599599 pub fn span_until_non_whitespace ( & self , sp : Span ) -> Span {
600600 if let Ok ( snippet) = self . span_to_snippet ( sp) {
601- let mut offset = 0 ;
602- let mut pos = 0 ;
601+ let mut offset = 1 ;
603602 // 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 ( ) ) {
605604 offset += c. len_utf8 ( ) ;
606- pos = i + 1 ;
607605 }
608606 // 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 ( ) ) {
610608 offset += c. len_utf8 ( ) ;
611609 }
612- if offset != 0 {
610+ if offset > 1 {
613611 return sp. with_hi ( BytePos ( sp. lo ( ) . 0 + offset as u32 ) ) ;
614612 }
615613 }
You can’t perform that action at this time.
0 commit comments