mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-26 03:35:17 +00:00
Minor refactoring to reuse autosuggestion contructor
This commit is contained in:
parent
1d620356f8
commit
e8801d2ced
1 changed files with 12 additions and 8 deletions
|
@ -4407,22 +4407,26 @@ fn get_autosuggestion_performer(
|
||||||
let complete_flags = CompletionRequestOptions::autosuggest();
|
let complete_flags = CompletionRequestOptions::autosuggest();
|
||||||
let (mut completions, needs_load) = complete(&search_string, complete_flags, &ctx);
|
let (mut completions, needs_load) = complete(&search_string, complete_flags, &ctx);
|
||||||
|
|
||||||
let mut result = Autosuggestion::default();
|
let full_line = if completions.is_empty() {
|
||||||
result.search_string = search_string.to_owned();
|
WString::new()
|
||||||
result.needs_load = needs_load;
|
} else {
|
||||||
result.icase = true; // normal completions are case-insensitive
|
|
||||||
if !completions.is_empty() {
|
|
||||||
sort_and_prioritize(&mut completions, complete_flags);
|
sort_and_prioritize(&mut completions, complete_flags);
|
||||||
let comp = &completions[0];
|
let comp = &completions[0];
|
||||||
let mut cursor = cursor_pos;
|
let mut cursor = cursor_pos;
|
||||||
result.text = completion_apply_to_command_line(
|
completion_apply_to_command_line(
|
||||||
&comp.completion,
|
&comp.completion,
|
||||||
comp.flags,
|
comp.flags,
|
||||||
&search_string,
|
&search_string,
|
||||||
&mut cursor,
|
&mut cursor,
|
||||||
/*append_only=*/ true,
|
/*append_only=*/ true,
|
||||||
|
)
|
||||||
|
};
|
||||||
|
let mut result = Autosuggestion::new(
|
||||||
|
full_line,
|
||||||
|
search_string.to_owned(),
|
||||||
|
true, // normal completions are case-insensitive
|
||||||
);
|
);
|
||||||
}
|
result.needs_load = needs_load;
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue