diff --git a/src/complete.rs b/src/complete.rs index 2fac1a36d..c01cf241b 100644 --- a/src/complete.rs +++ b/src/complete.rs @@ -32,8 +32,7 @@ use fish_util::wcsfilecmp; use fish_wcstringutil::{ StringFuzzyMatch, string_fuzzy_match_string, string_prefixes_string, - string_prefixes_string_case_insensitive, string_suffixes_string_case_insensitive, - strip_executable_suffix, + string_suffixes_string_case_insensitive, strip_executable_suffix, }; use fish_widestring::{WExt as _, charptr2wcstring}; use std::{ @@ -160,12 +159,14 @@ pub fn new( flags: CompleteFlags, ) -> Self { let flags = resolve_auto_space(&completion, flags); - Self { + let zelf = Self { completion, description, r#match, flags, - } + }; + assert!(!zelf.r#match.requires_full_replacement() || zelf.replaces_token()); + zelf } pub fn from_completion(completion: WString) -> Self { @@ -1508,7 +1509,7 @@ fn complete_param_for_command( if !self.completions.add(Completion::new( completion, o.desc.localize().to_owned(), - StringFuzzyMatch::exact_match(), + r#match, flags | CompleteFlags::NO_SPACE, )) { return false; @@ -1519,7 +1520,7 @@ fn complete_param_for_command( if !self.completions.add(Completion::new( whole_opt.slice_from(offset).to_owned(), o.desc.localize().to_owned(), - StringFuzzyMatch::exact_match(), + r#match, flags, )) { return false; diff --git a/tests/checks/tmux-complete4.fish b/tests/checks/tmux-complete4.fish new file mode 100644 index 000000000..5720ee1bd --- /dev/null +++ b/tests/checks/tmux-complete4.fish @@ -0,0 +1,30 @@ +#RUN: %fish %s +#REQUIRES: command -v tmux +#REQUIRES: uname -r | grep -qv Microsoft + +isolated-tmux-start -C ' + complete : -s c -l clip + complete : -s q -l qrcode + set -g fish_autosuggestion_enabled 0 +' +touch somefile1 +touch somefile2 + +isolated-tmux send-keys C-l ': -c' + +function tab + isolated-tmux send-keys Tab + tmux-sleep + isolated-tmux capture-pane -p | sed '/./ { s,^,[,; s,$,], }' +end + +tab +# CHECK: [prompt 0> : -cq] + +tab +# CHECK: [prompt 0> : -cq somefile] +# CHECK: [somefile1 somefile2] + +tab +# CHECK: [prompt 0> : -cq somefile1] +# CHECK: [somefile1 somefile2]