@@ -66,7 +66,7 @@ impl WideChar {
66
66
}
67
67
68
68
/// Returns the length in UTF-16 or UTF-32 code units.
69
- fn wide_len ( & self , enc : WideEncoding ) -> usize {
69
+ fn wide_len ( & self , enc : WideEncoding ) -> u32 {
70
70
match enc {
71
71
WideEncoding :: Utf16 => {
72
72
if self . len ( ) == TextSize :: from ( 4 ) {
@@ -75,7 +75,6 @@ impl WideChar {
75
75
1
76
76
}
77
77
}
78
-
79
78
WideEncoding :: Utf32 => 1 ,
80
79
}
81
80
}
@@ -157,20 +156,19 @@ impl LineIndex {
157
156
158
157
/// Transforms the `LineCol` with the given `WideEncoding` into a `WideLineCol`.
159
158
pub fn to_wide ( & self , enc : WideEncoding , line_col : LineCol ) -> Option < WideLineCol > {
160
- let col: TextSize = line_col. col . into ( ) ;
161
- let mut res: usize = col. into ( ) ;
159
+ let mut col = line_col. col ;
162
160
if let Some ( wide_chars) = self . line_wide_chars . get ( & line_col. line ) {
163
161
for c in wide_chars. iter ( ) {
164
162
if u32:: from ( c. end ) <= line_col. col {
165
- res -= usize :: from ( c. len ( ) ) - c. wide_len ( enc) ;
163
+ col -= u32 :: from ( c. len ( ) ) - c. wide_len ( enc) ;
166
164
} else {
167
165
// From here on, all utf16 characters come *after* the character we are mapping,
168
166
// so we don't need to take them into account
169
167
break ;
170
168
}
171
169
}
172
170
}
173
- Some ( WideLineCol { line : line_col. line , col : res as u32 } )
171
+ Some ( WideLineCol { line : line_col. line , col } )
174
172
}
175
173
176
174
/// Transforms the `WideLineCol` with the given `WideEncoding` into a `LineCol`.
0 commit comments