mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-09 03:51:20 -03:00
Fix option substr completions not being filtered out
Commit 3546ffa3ef (reader handle_completions(): remove dead filtering code,
2026-01-02) gives a proof of correctness that still makes sense;
The first lemma ("if will_replace_token") is trivially true, so no need to
assert it.
The second lemma ("if !will_replace_token") is violated in some edge cases:
we claim that given a token "-c", the option completion "--clip" is an exact match,
which is not true, it's a substring match.
Fix that, asserting the claim.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user