mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-28 12:45:13 +00:00
Swap code blocks for completing separator suffix resp. whole token
Mainly to make the next commit's diff smaller. Not much functional change: since file completions never have the DONT_SORT flag set, these results will be sorted, and there are no data dependencies -- unless we're overflowing the max number of completions. But in that case the whole-token completions seem more important anyway.
This commit is contained in:
parent
b46417c77b
commit
0cfc95993a
1 changed files with 38 additions and 36 deletions
|
@ -1584,7 +1584,36 @@ impl<'ctx> Completer<'ctx> {
|
|||
};
|
||||
let complete_from_start = sep_index.is_none() || !string_prefixes_string(L!("-"), s);
|
||||
|
||||
if let Some(sep_index) = sep_index {
|
||||
if complete_from_start {
|
||||
let mut flags = flags;
|
||||
// Don't do fuzzy matching for files if the string begins with a dash (issue #568). We could
|
||||
// consider relaxing this if there was a preceding double-dash argument.
|
||||
if string_prefixes_string(L!("-"), s) {
|
||||
flags -= ExpandFlags::FUZZY_MATCH;
|
||||
}
|
||||
|
||||
let first = self.completions.len();
|
||||
if matches!(
|
||||
expand_to_receiver(s.to_owned(), &mut self.completions, flags, self.ctx, None)
|
||||
.result,
|
||||
ExpandResultCode::error | ExpandResultCode::overflow,
|
||||
) {
|
||||
FLOGF!(complete, "Error while expanding string '%ls'", s);
|
||||
}
|
||||
Self::escape_opening_brackets(&mut self.completions[first..], s);
|
||||
let have_token = !s.is_empty();
|
||||
Self::escape_separators(
|
||||
&mut self.completions[first..],
|
||||
variable_override_prefix,
|
||||
self.flags.autosuggestion,
|
||||
have_token,
|
||||
quoted,
|
||||
);
|
||||
}
|
||||
|
||||
let Some(sep_index) = sep_index else {
|
||||
return;
|
||||
};
|
||||
let sep_string = s.slice_from(sep_index + 1);
|
||||
let mut local_completions = Vec::new();
|
||||
if matches!(
|
||||
|
@ -1620,33 +1649,6 @@ impl<'ctx> Completer<'ctx> {
|
|||
}
|
||||
}
|
||||
|
||||
if complete_from_start {
|
||||
// Don't do fuzzy matching for files if the string begins with a dash (issue #568). We could
|
||||
// consider relaxing this if there was a preceding double-dash argument.
|
||||
if string_prefixes_string(L!("-"), s) {
|
||||
flags -= ExpandFlags::FUZZY_MATCH;
|
||||
}
|
||||
|
||||
let first = self.completions.len();
|
||||
if matches!(
|
||||
expand_to_receiver(s.to_owned(), &mut self.completions, flags, self.ctx, None)
|
||||
.result,
|
||||
ExpandResultCode::error | ExpandResultCode::overflow,
|
||||
) {
|
||||
FLOGF!(complete, "Error while expanding string '%ls'", s);
|
||||
}
|
||||
Self::escape_opening_brackets(&mut self.completions[first..], s);
|
||||
let have_token = !s.is_empty();
|
||||
Self::escape_separators(
|
||||
&mut self.completions[first..],
|
||||
variable_override_prefix,
|
||||
self.flags.autosuggestion,
|
||||
have_token,
|
||||
quoted,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn escape_separators(
|
||||
completions: &mut [Completion],
|
||||
variable_override_prefix: &wstr,
|
||||
|
|
Loading…
Reference in a new issue