1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

tools: fix vcompletion for single-file directories (#16586)

This commit is contained in:
Larpon 2022-12-05 08:15:43 +01:00 committed by GitHub
parent ce06c2818d
commit 349ce08a11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -518,6 +518,17 @@ fn auto_complete_request(args []string) []string {
}
}
} else {
// Handle special case, where there is only one file in the directory
// being completed - if it can be resolved we return that since
// handling it in the generalized logic below will result in
// more complexity.
if entries.len == 1 && os.is_file(os.join_path(ls_path, entries[0])) {
mut keep_input_path_format := ls_path
if !part.starts_with('./') && ls_path.starts_with('./') {
keep_input_path_format = keep_input_path_format.all_after('./')
}
return [os.join_path(keep_input_path_format, entries[0])]
}
for entry in entries {
if collect_all || entry.starts_with(last) {
list << append_separator_if_dir(entry)