Skip to content

Conversation

@SimoneDutto
Copy link

@SimoneDutto SimoneDutto commented Dec 20, 2025

Description

Before the fuzzy matching was skipped when not all characters could be matched. Now it's changed in favor of getting the score for the number of characters that match.

By debugging and trying to understand the current scoring mechanism I think I've understood m.scores is a matrix [length-candidate][length-pattern][another-dim].

Before it was getting the score always from len(candidate) and len(pattern), but this is wrong in case we know the pattern has x amount of char actually matching.

So:

  • now match requires full matching chars for short candidate
  • now the score is get from len(candidate), num of matching chars in pattern.

Unit tests

I've added a few unit tests I thought showed the improvement.
Without my patch the failures in the new test cases are:

/tools/gopls/internal/fuzzy/matcher_test.go:270: Score(tstincrementatlnope, TestIncrementalNope) = 0, want: 0.61842
/tools/gopls/internal/fuzzy/matcher_test.go:270: Score(testssssss, TestIncrementalNope) = 0, want: 0.4

Manual QA

By trying to use the examples in the issue are satisfied, and in general it seems to match broader. I'm not entirely sure how to test false positives.

Fix: golang/go#74793

Before the fuzzy matching was skipped when not all characters could be
matched. Now it's changed in favor of getting the score for the number
of characters that match.
@google-cla
Copy link

google-cla bot commented Dec 20, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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.

x/tools/gopls: Symbols: use Levenshtein distance for ranking

1 participant