mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-19 23:02:44 +08:00
Apply code review fixes
This commit is contained in:
parent
d6a9ad66a7
commit
5407d0b785
|
@ -160,12 +160,6 @@ impl CompletionReceiver {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Swap our completions with a new list.
|
|
||||||
pub fn swap(&mut self, lst: &mut Vec<Completion>) {
|
|
||||||
// XXX: This completly breaks our completions.len() <= self.limit invariant
|
|
||||||
std::mem::swap(&mut self.completions, lst);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Clear the list of completions. This retains the storage inside completions_ which can be
|
/// Clear the list of completions. This retains the storage inside completions_ which can be
|
||||||
/// useful to prevent allocations.
|
/// useful to prevent allocations.
|
||||||
pub fn clear(&mut self) {
|
pub fn clear(&mut self) {
|
||||||
|
|
|
@ -69,13 +69,9 @@ fn resolve_description<'f>(
|
||||||
) -> WString {
|
) -> WString {
|
||||||
if let Some(complete_sep_loc) = completion.find_char(PROG_COMPLETE_SEP) {
|
if let Some(complete_sep_loc) = completion.find_char(PROG_COMPLETE_SEP) {
|
||||||
// This completion has an embedded description, do not use the generic description.
|
// This completion has an embedded description, do not use the generic description.
|
||||||
assert!(
|
let description = completion[complete_sep_loc + 1..].to_owned();
|
||||||
completion.len() > complete_sep_loc,
|
*completion = &completion[..complete_sep_loc];
|
||||||
"resolve_description lacks a length assumption"
|
return description;
|
||||||
);
|
|
||||||
let (comp, description) = completion.split_at(complete_sep_loc + 1);
|
|
||||||
*completion = comp;
|
|
||||||
return description.to_owned();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(f) = description_func {
|
if let Some(f) = description_func {
|
||||||
|
@ -143,7 +139,7 @@ fn wildcard_complete_internal(
|
||||||
|
|
||||||
// If we're not allowing fuzzy match, then we require a prefix match.
|
// If we're not allowing fuzzy match, then we require a prefix match.
|
||||||
let needs_prefix_match = !params.expand_flags.contains(ExpandFlags::FUZZY_MATCH);
|
let needs_prefix_match = !params.expand_flags.contains(ExpandFlags::FUZZY_MATCH);
|
||||||
if needs_prefix_match && m.is_exact_or_prefix() {
|
if needs_prefix_match && !m.is_exact_or_prefix() {
|
||||||
return WildcardResult::NoMatch;
|
return WildcardResult::NoMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,11 +460,11 @@ fn wildcard_test_flags_then_complete(
|
||||||
|
|
||||||
// Append a / if this is a directory. Note this requirement may be the only reason we have to
|
// Append a / if this is a directory. Note this requirement may be the only reason we have to
|
||||||
// call stat() in some cases.
|
// call stat() in some cases.
|
||||||
let x = |_: &wstr| match desc.as_ref() {
|
let desc_func = |_: &wstr| match desc.as_ref() {
|
||||||
Some(d) => d.to_owned(),
|
Some(d) => d.to_owned(),
|
||||||
None => WString::new(),
|
None => WString::new(),
|
||||||
};
|
};
|
||||||
let desc_func: Option<&dyn Fn(&wstr) -> WString> = Some(&x);
|
let desc_func: Option<&dyn Fn(&wstr) -> WString> = Some(&desc_func);
|
||||||
if is_directory {
|
if is_directory {
|
||||||
return wildcard_complete(
|
return wildcard_complete(
|
||||||
&(filename.to_owned() + L!("/")),
|
&(filename.to_owned() + L!("/")),
|
||||||
|
@ -874,7 +870,7 @@ mod expander {
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
|
||||||
if need_dir && entry.is_dir() {
|
if need_dir && !entry.is_dir() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user