Return input on autocomplete when no results

This commit is contained in:
Justine
2023-02-05 00:37:42 +01:00
parent a2726d4557
commit 2dd83d0097

View File

@ -86,13 +86,18 @@ impl Search {
///Performs the search and returns (most likely result, result lines to display) ///Performs the search and returns (most likely result, result lines to display)
///A found file is preferred to a found command ///A found file is preferred to a found command
pub fn autocomplete(&self) -> (String, String) { pub fn autocomplete(&self) -> (String, String) {
let (res, res_lines) = match &self.search_type { let (mut res, res_lines) = match &self.search_type {
SearchType::CmdSearch => autocomplete_cmd(&self.searchee), SearchType::CmdSearch => autocomplete_cmd(&self.searchee),
SearchType::FileSearch => match autocomplete_file(&self) { SearchType::FileSearch => match autocomplete_file(&self) {
Ok(t) => t, Ok(t) => t,
Err(_) => (String::new(), String::new()), Err(_) => (String::new(), String::new()),
} }
}; };
if res.len() < 1 {
*&mut res = format!("{} {}", &self.command, &self.searchee);
}
return (res, res_lines); return (res, res_lines);
} }