mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-15 14:41:14 -03:00
Make abbreviation completions shadow commands
As reported in https://matrix.to/#/!YLTeaulxSDauOOxBoR:matrix.org/$yD_Lutaftf6ytk617kjw5vC-k_OgHRQxIiSRv89uBMI it's weird that command name completions shadow abbreviation name completions, given that the abbreviation will the one that will be executed in the typical cases. Let's put abbreviation completions first; unique_completions_retaining_order() will take care of removing any command completions we add later.
This commit is contained in:
@@ -776,8 +776,8 @@ fn perform_for_commandline_impl(&mut self, cmdline: WString) {
|
|||||||
}
|
}
|
||||||
// Complete command filename.
|
// Complete command filename.
|
||||||
let current_token = current_token.to_owned();
|
let current_token = current_token.to_owned();
|
||||||
self.complete_cmd(current_token.clone());
|
self.complete_abbr(current_token.clone());
|
||||||
self.complete_abbr(current_token);
|
self.complete_cmd(current_token);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// See whether we are in an argument, in a redirection or in the whitespace in between.
|
// See whether we are in an argument, in a redirection or in the whitespace in between.
|
||||||
|
|||||||
@@ -387,14 +387,14 @@ macro_rules! unique_completion_applies_as {
|
|||||||
)
|
)
|
||||||
.0;
|
.0;
|
||||||
assert_eq!(completions.len(), 2);
|
assert_eq!(completions.len(), 2);
|
||||||
assert_eq!(completions[0].completion, L!("four"));
|
|
||||||
assert!(!completions[0].flags.contains(CompleteFlags::NO_SPACE));
|
|
||||||
// Abbreviations should not have a space after them.
|
// Abbreviations should not have a space after them.
|
||||||
assert_eq!(completions[1].completion, L!("zero"));
|
assert_eq!(completions[0].completion, L!("zero"));
|
||||||
assert!(completions[1].flags.contains(CompleteFlags::NO_SPACE));
|
assert!(completions[0].flags.contains(CompleteFlags::NO_SPACE));
|
||||||
with_abbrs_mut(|abbrset| {
|
with_abbrs_mut(|abbrset| {
|
||||||
abbrset.erase(L!("testabbrsonetwothreezero"));
|
abbrset.erase(L!("testabbrsonetwothreezero"));
|
||||||
});
|
});
|
||||||
|
assert_eq!(completions[1].completion, L!("four"));
|
||||||
|
assert!(!completions[1].flags.contains(CompleteFlags::NO_SPACE));
|
||||||
|
|
||||||
// Test wraps.
|
// Test wraps.
|
||||||
assert!(comma_join(complete_get_wrap_targets(L!("wrapper1"))).is_empty());
|
assert!(comma_join(complete_get_wrap_targets(L!("wrapper1"))).is_empty());
|
||||||
|
|||||||
@@ -629,3 +629,7 @@ complete -C'testcommand '
|
|||||||
# CHECK: check{{\t}}Check the frobnicator
|
# CHECK: check{{\t}}Check the frobnicator
|
||||||
# CHECK: search{{\t}}Search for frobs
|
# CHECK: search{{\t}}Search for frobs
|
||||||
# CHECK: show{{\t}}Show all frobs
|
# CHECK: show{{\t}}Show all frobs
|
||||||
|
|
||||||
|
abbr cat cat
|
||||||
|
complete -C ca | string match -r '^cat(?:\t.*)?$'
|
||||||
|
# CHECK: cat{{\t}}Abbreviation: cat
|
||||||
|
|||||||
Reference in New Issue
Block a user