File tree 2 files changed +4
-10
lines changed
2 files changed +4
-10
lines changed Original file line number Diff line number Diff line change @@ -128,7 +128,7 @@ impl Scanner {
128
128
input : ChangedContent ,
129
129
) -> Vec < CandidateWithPosition > {
130
130
let content = input. content . unwrap_or_else ( || {
131
- std:: fs:: read_to_string ( & input. file . unwrap ( ) ) . expect ( "Failed to read file" )
131
+ std:: fs:: read_to_string ( input. file . unwrap ( ) ) . expect ( "Failed to read file" )
132
132
} ) ;
133
133
134
134
let input = ChangedContent {
Original file line number Diff line number Diff line change @@ -31,20 +31,18 @@ impl<'a> IndexConverter<'a> {
31
31
// will only ever be incremented up to the length of the input string.
32
32
//
33
33
// This eliminates a "potential" panic that cannot actually happen
34
- let slice = unsafe {
35
- self . input . get_unchecked ( self . curr_utf8 ..)
36
- } ;
34
+ let slice = unsafe { self . input . get_unchecked ( self . curr_utf8 ..) } ;
37
35
38
36
for c in slice. chars ( ) {
39
37
if self . curr_utf8 >= pos {
40
- break
38
+ break ;
41
39
}
42
40
43
41
self . curr_utf8 += c. len_utf8 ( ) ;
44
42
self . curr_utf16 += c. len_utf16 ( ) ;
45
43
}
46
44
47
- return self . curr_utf16 as i64 ;
45
+ self . curr_utf16 as i64
48
46
}
49
47
}
50
48
@@ -66,19 +64,16 @@ mod test {
66
64
( 4 , 4 ) ,
67
65
( 5 , 5 ) ,
68
66
( 6 , 6 ) ,
69
-
70
67
// inside the 🔥
71
68
( 7 , 8 ) ,
72
69
( 8 , 8 ) ,
73
70
( 9 , 8 ) ,
74
71
( 10 , 8 ) ,
75
-
76
72
// inside the 🥳
77
73
( 11 , 10 ) ,
78
74
( 12 , 10 ) ,
79
75
( 13 , 10 ) ,
80
76
( 14 , 10 ) ,
81
-
82
77
// <space>world!
83
78
( 15 , 11 ) ,
84
79
( 16 , 12 ) ,
@@ -87,7 +82,6 @@ mod test {
87
82
( 19 , 15 ) ,
88
83
( 20 , 16 ) ,
89
84
( 21 , 17 ) ,
90
-
91
85
// Past the end should return the last utf-16 character index
92
86
( 22 , 17 ) ,
93
87
( 100 , 17 ) ,
You can’t perform that action at this time.
0 commit comments