Autocomplete to longest string when searching commands
This commit is contained in:
parent
56e5d4e63d
commit
ad0dde7232
@ -220,7 +220,7 @@ fn autocomplete_file(search: &Search) -> std::io::Result<(String, String)> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
last_found = last_found.replace("./", "");
|
//last_found = last_found.replace("./", "");
|
||||||
|
|
||||||
//Otherwise... Handling the return as gracefully as I can
|
//Otherwise... Handling the return as gracefully as I can
|
||||||
let mut return_val = String::new();
|
let mut return_val = String::new();
|
||||||
@ -266,7 +266,9 @@ fn autocomplete_cmd(input: &String, search: &Search) -> (String, String) {
|
|||||||
} else {
|
} else {
|
||||||
let mut all_res = String::new();
|
let mut all_res = String::new();
|
||||||
let mut counter = 0;
|
let mut counter = 0;
|
||||||
|
let mut bins = Vec::new();
|
||||||
for path in found_bins {
|
for path in found_bins {
|
||||||
|
//Show 40 results max
|
||||||
if counter < 40 {
|
if counter < 40 {
|
||||||
let buff = String::from(path
|
let buff = String::from(path
|
||||||
.iter()
|
.iter()
|
||||||
@ -274,6 +276,7 @@ fn autocomplete_cmd(input: &String, search: &Search) -> (String, String) {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap());
|
.unwrap());
|
||||||
|
*&mut bins.push(buff.clone());
|
||||||
let res_line = format!("* {}\r\n", buff);
|
let res_line = format!("* {}\r\n", buff);
|
||||||
all_res.push_str(&res_line);
|
all_res.push_str(&res_line);
|
||||||
counter += 1;
|
counter += 1;
|
||||||
@ -283,8 +286,8 @@ fn autocomplete_cmd(input: &String, search: &Search) -> (String, String) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let first_res = String::from(input);
|
let longest = find_common_chars(bins);
|
||||||
let ret_line = format!("{}{}", &search.command, first_res);
|
let ret_line = format!("{}", longest);
|
||||||
return(ret_line, all_res);
|
return(ret_line, all_res);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user