File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed
Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -37,11 +37,11 @@ impl Completer for DotNuCompletion {
3737
3838 let ( base, partial) = if prefix_str == "~" {
3939 ( "~" , "" )
40- } else if let Some ( ( parent, remain) ) = prefix_str. split_once ( is_separator) {
40+ } else if let Some ( ( parent, remain) ) = prefix_str. rsplit_once ( is_separator) {
4141 // If prefix_str is only a word we want to search in the current dir.
4242 // "/xx" should be split to "/" and "xx".
4343 if parent. is_empty ( ) {
44- ( "/" , remain)
44+ ( MAIN_SEPARATOR_STR , remain)
4545 } else {
4646 ( parent, remain)
4747 }
@@ -125,7 +125,7 @@ impl Completer for DotNuCompletion {
125125 let mut span_offset = 0 ;
126126 let mut value = x. path . to_string ( ) ;
127127 // Complete only the last path component
128- if base_dir == "/" {
128+ if base_dir == MAIN_SEPARATOR_STR {
129129 span_offset = base_dir. len ( )
130130 } else if base_dir != "." {
131131 span_offset = base_dir. len ( ) + 1
Original file line number Diff line number Diff line change @@ -343,6 +343,20 @@ fn dotnu_completions() {
343343 let suggestions = completer. complete ( & completion_str, completion_str. len ( ) ) ;
344344
345345 match_suggestions ( & expected, & suggestions) ;
346+
347+ // Test special paths
348+ #[ cfg( windows) ]
349+ let completion_str = "use \\ b" . to_string ( ) ;
350+ #[ cfg( not( windows) ) ]
351+ let completion_str = "use /b" . to_string ( ) ;
352+ let suggestions = completer. complete ( & completion_str, completion_str. len ( ) ) ;
353+
354+ assert ! ( !suggestions. is_empty( ) ) ;
355+
356+ let completion_str = "use ~" . to_string ( ) ;
357+ let suggestions = completer. complete ( & completion_str, completion_str. len ( ) ) ;
358+
359+ assert ! ( !suggestions. is_empty( ) ) ;
346360}
347361
348362#[ test]
You can’t perform that action at this time.
0 commit comments