File tree 1 file changed +25
-1
lines changed
1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -320,7 +320,7 @@ impl SearchMode {
320
320
} ;
321
321
match m {
322
322
Some ( ( index, _) ) => {
323
- name = & name[ index + 1 ..] ;
323
+ name = & name[ ceil_char_boundary ( name , index + 1 ) ..] ;
324
324
true
325
325
}
326
326
None => false ,
@@ -331,6 +331,12 @@ impl SearchMode {
331
331
}
332
332
}
333
333
334
+ // FIXME: use `ceil_char_boundary` from `std::str` when it gets stable
335
+ // https://github.com/rust-lang/rust/issues/93743
336
+ fn ceil_char_boundary ( text : & str , index : usize ) -> usize {
337
+ ( index..) . find ( |& index| text. is_char_boundary ( index) ) . unwrap_or ( text. len ( ) )
338
+ }
339
+
334
340
/// Three possible ways to search for the name in associated and/or other items.
335
341
#[ derive( Debug , Clone , Copy ) ]
336
342
pub enum AssocSearchMode {
@@ -1043,4 +1049,22 @@ pub mod fmt {
1043
1049
"# ] ] ,
1044
1050
) ;
1045
1051
}
1052
+
1053
+ #[ test]
1054
+ fn unicode_fn_name ( ) {
1055
+ let ra_fixture = r#"
1056
+ //- /main.rs crate:main deps:dep
1057
+ //- /dep.rs crate:dep
1058
+ pub fn あい() {}
1059
+ "# ;
1060
+
1061
+ check_search (
1062
+ ra_fixture,
1063
+ "main" ,
1064
+ Query :: new ( "あ" . to_owned ( ) ) . fuzzy ( ) ,
1065
+ expect ! [ [ r#"
1066
+ dep::あい (f)
1067
+ "# ] ] ,
1068
+ ) ;
1069
+ }
1046
1070
}
You can’t perform that action at this time.
0 commit comments