@@ -77,6 +77,7 @@ pub(crate) fn complete_path(
77
77
is_wanted : & dyn Fn ( & std:: path:: Path ) -> bool ,
78
78
) -> Vec < CompletionCandidate > {
79
79
let mut completions = Vec :: new ( ) ;
80
+ let mut potential = Vec :: new ( ) ;
80
81
81
82
let value_path = std:: path:: Path :: new ( value_os) ;
82
83
let ( prefix, current) = split_file_name ( value_path) ;
@@ -88,7 +89,7 @@ pub(crate) fn complete_path(
88
89
Some ( current_dir) => current_dir,
89
90
None => {
90
91
// Can't complete without a `current_dir`
91
- return Vec :: new ( ) ;
92
+ return completions ;
92
93
}
93
94
} ;
94
95
current_dir. join ( prefix)
@@ -109,15 +110,24 @@ pub(crate) fn complete_path(
109
110
if entry. metadata ( ) . map ( |m| m. is_dir ( ) ) . unwrap_or ( false ) {
110
111
let mut suggestion = prefix. join ( raw_file_name) ;
111
112
suggestion. push ( "" ) ; // Ensure trailing `/`
112
- completions. push ( CompletionCandidate :: new ( suggestion. as_os_str ( ) . to_owned ( ) ) ) ;
113
+ let candidate = CompletionCandidate :: new ( suggestion. as_os_str ( ) . to_owned ( ) ) ;
114
+
115
+ if is_wanted ( & entry. path ( ) ) {
116
+ completions. push ( candidate) ;
117
+ } else {
118
+ potential. push ( candidate) ;
119
+ }
113
120
} else {
114
- let path = entry. path ( ) ;
115
- if is_wanted ( & path) {
121
+ if is_wanted ( & entry. path ( ) ) {
116
122
let suggestion = prefix. join ( raw_file_name) ;
117
- completions. push ( CompletionCandidate :: new ( suggestion. as_os_str ( ) . to_owned ( ) ) ) ;
123
+ let candidate = CompletionCandidate :: new ( suggestion. as_os_str ( ) . to_owned ( ) ) ;
124
+ completions. push ( candidate) ;
118
125
}
119
126
}
120
127
}
128
+ completions. sort ( ) ;
129
+ potential. sort ( ) ;
130
+ completions. extend ( potential) ;
121
131
122
132
completions
123
133
}
0 commit comments