diff --git a/src/complete.rs b/src/complete.rs index d1baf69fd..87ae3b3b0 100644 --- a/src/complete.rs +++ b/src/complete.rs @@ -776,8 +776,8 @@ fn perform_for_commandline_impl(&mut self, cmdline: WString) { } // Complete command filename. let current_token = current_token.to_owned(); - self.complete_cmd(current_token.clone()); - self.complete_abbr(current_token); + self.complete_abbr(current_token.clone()); + self.complete_cmd(current_token); return; } // See whether we are in an argument, in a redirection or in the whitespace in between. diff --git a/src/tests/complete.rs b/src/tests/complete.rs index 316ce0a94..9302b55c5 100644 --- a/src/tests/complete.rs +++ b/src/tests/complete.rs @@ -387,14 +387,14 @@ macro_rules! unique_completion_applies_as { ) .0; 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. - assert_eq!(completions[1].completion, L!("zero")); - assert!(completions[1].flags.contains(CompleteFlags::NO_SPACE)); + assert_eq!(completions[0].completion, L!("zero")); + assert!(completions[0].flags.contains(CompleteFlags::NO_SPACE)); with_abbrs_mut(|abbrset| { abbrset.erase(L!("testabbrsonetwothreezero")); }); + assert_eq!(completions[1].completion, L!("four")); + assert!(!completions[1].flags.contains(CompleteFlags::NO_SPACE)); // Test wraps. assert!(comma_join(complete_get_wrap_targets(L!("wrapper1"))).is_empty()); diff --git a/tests/checks/complete.fish b/tests/checks/complete.fish index 0330eced8..78d633e61 100644 --- a/tests/checks/complete.fish +++ b/tests/checks/complete.fish @@ -629,3 +629,7 @@ complete -C'testcommand ' # CHECK: check{{\t}}Check the frobnicator # CHECK: search{{\t}}Search for frobs # CHECK: show{{\t}}Show all frobs + +abbr cat cat +complete -C ca | string match -r '^cat(?:\t.*)?$' +# CHECK: cat{{\t}}Abbreviation: cat