File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -736,12 +736,13 @@ impl NormalizedString {
736
736
} ;
737
737
738
738
if leading_spaces > 0 || trailing_spaces > 0 {
739
+ let count = self . get ( ) . chars ( ) . count ( ) ;
739
740
let transformation = self
740
741
. normalized
741
742
. chars ( )
742
743
. enumerate ( )
743
744
. filter_map ( |( i, c) | {
744
- if i < leading_spaces || i >= self . len ( ) - trailing_spaces {
745
+ if i < leading_spaces || i >= count - trailing_spaces {
745
746
None
746
747
} else if i == self . len ( ) - trailing_spaces - 1 {
747
748
Some ( ( c, -( trailing_spaces as isize ) ) )
@@ -1274,6 +1275,17 @@ mod tests {
1274
1275
) ;
1275
1276
}
1276
1277
1278
+ #[ test]
1279
+ fn strip_unicode ( ) {
1280
+ let mut n = NormalizedString :: from ( " 你好asa \n " ) ;
1281
+ n. strip ( ) ;
1282
+ assert_eq ! ( & n. normalized, "你好asa" ) ;
1283
+ assert_eq ! (
1284
+ n. get_range_original( Range :: Normalized ( 0 ..n. normalized. len( ) ) ) ,
1285
+ Some ( "你好asa" )
1286
+ ) ;
1287
+ }
1288
+
1277
1289
#[ test]
1278
1290
fn prepend ( ) {
1279
1291
let mut n = NormalizedString :: from ( "there" ) ;
You can’t perform that action at this time.
0 commit comments