Skip to content

Conversation

@hanspinckaers
Copy link

Hi there,

I often mistype, or create a small typo, needing to backspace. On backspace I can retrigger autocomplete, but then I loose the previous results / fuzzy filtering. This commit adds a bit more leeway for making typing errors.

Thanks for the plugin and work!

@hanspinckaers
Copy link
Author

Still fine-tuning the code, will correct later

@fannheyward fannheyward marked this pull request as draft February 6, 2025 06:22
@chemzqm chemzqm marked this pull request as ready for review March 5, 2025 12:38
@hanspinckaers hanspinckaers reopened this Apr 19, 2025
@fannheyward fannheyward requested a review from Copilot November 27, 2025 01:51
Copilot finished reviewing on behalf of fannheyward November 27, 2025 01:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the fuzzy matching algorithm to be more resilient to typing errors by adding character removal strategies alongside the existing character permutation approach. When a user makes a typo while typing, the enhanced algorithm can now match patterns even when extra characters are present in the search string.

Key Changes

  • Extended the typo-correction algorithm to try removing characters at any position in the pattern (not just permutations)
  • Added specific handling for removing the last 1-2 characters, which are common typo locations
  • Introduced a penalty-based scoring system to rank different correction strategies
  • Refactored the permutation loop logic for consistency
Comments suppressed due to low confidence (1)

src/util/filter.ts:89

  • Unused variable maxTries.
    const maxTries = maxTriesPermutation + pattern.length;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 103 to 109
checkAndUpdateTopCandidate(newPattern, 4);
}

// Loop for removing last characters
for (let i = 1; i < 3; i++) {
const newPattern = pattern.slice(0, pattern.length - i);
checkAndUpdateTopCandidate(newPattern, i+4);
Copy link

Copilot AI Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The penalty system is inconsistent and potentially incorrect:

  • Character permutations (line 94): penalty of 3
  • Removing any character at any position (line 103): penalty of 4
  • Removing last 1 character (line 109 when i=1): penalty of 5
  • Removing last 2 characters (line 109 when i=2): penalty of 6

This means removing the last character has a higher penalty (5) than removing a character in the middle (4), which seems counterintuitive since typos at the end are more common than in the middle. Consider revising the penalty structure to be more logical, for example:

  • Permutations: 3
  • Remove last 1 char: 4
  • Remove last 2 chars: 5
  • Remove middle chars: 6 (higher penalty since less likely to be a typo)
Suggested change
checkAndUpdateTopCandidate(newPattern, 4);
}
// Loop for removing last characters
for (let i = 1; i < 3; i++) {
const newPattern = pattern.slice(0, pattern.length - i);
checkAndUpdateTopCandidate(newPattern, i+4);
// Penalty 6 for removing middle chars (less likely typo)
checkAndUpdateTopCandidate(newPattern, 6);
}
// Loop for removing last characters
for (let i = 1; i < 3; i++) {
// Penalty 4 for last char, 5 for last two chars
checkAndUpdateTopCandidate(newPattern, i + 3);

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants