reader handle_completions(): remove dead filtering code

We skip completions where "will_replace_token != c.replaces_token()".
This means that
- if will_replace_token, we filter out non-replacing completions.
  But those do not exist because, by definition, will_replace_token
  is true iff there are no non-replacing completions.
- if !will_replace_token, we filter out replacing completions.
  From the definition of will_replace_token follows that there is
  some non-replacing completion, which must be a prefix or exact match.
  Since we've filtered by rank, any replacing ones must have the same rank.
  So the replacement bit must be due to smartcase.  Smartcase
  completions are already passed through explicitly here since
  656b39a0b3 (Also show case-insensitive prefix matches in completion
  pager, 2025-11-23).

So the cases where we 'continue' here can never happen.
Remove this redundant check.
This commit is contained in:
Johannes Altmanninger
2026-01-02 12:35:55 +01:00
parent 30f96860a7
commit 3546ffa3ef

View File

@@ -6698,30 +6698,16 @@ fn best<T: Borrow<Completion>>(
// Decide which completions survived. There may be a lot of them; it would be nice if we could
// figure out how to avoid copying them here.
let mut surviving_completions = vec![];
for c in best(best_rank, comp.into_iter()) {
// Only use completions that match replace_token.
let completion_replaces_token = c.replaces_token();
let replaces_only_due_to_case_mismatch = {
completion_replaces_token
&& c.r#match.is_exact_or_prefix()
&& !matches!(c.r#match.case_fold, CaseSensitivity::Sensitive)
};
if completion_replaces_token != will_replace_token {
// Keep smart/samecase results even if we prefer not to replace the token.
if will_replace_token || !replaces_only_due_to_case_mismatch {
for mut c in best(best_rank, comp.into_iter()) {
if c.replaces_token() {
if !reader_can_replace(&tok, c.flags) {
continue;
}
if !will_replace_token {
c.flags |= CompleteFlags::SUPPRESS_PAGER_PREFIX;
}
}
// Don't use completions that want to replace, if we cannot replace them.
if completion_replaces_token && !reader_can_replace(&tok, c.flags) {
continue;
}
let mut c = c;
if replaces_only_due_to_case_mismatch && !will_replace_token {
c.flags |= CompleteFlags::SUPPRESS_PAGER_PREFIX;
}
surviving_completions.push(c);
}