-
Notifications
You must be signed in to change notification settings - Fork 680
Smarter fuzzy completion matches #1449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@scottnemes OK, the above is a better example. What The underscore part of the proposal here is to split terms on underscores, and match if every complete underscore-separated subword in the typed text is present in the candidate, independent of order. (But not every subword in the candidate needs to be covered, just some subset.) A further proposal for a followup PR would be to accept leading substrings, rather than requiring complete subwords, so that A further proposal for a followup PR would be to adopt some other library for fuzzy matching, as many smart people have already thought about this problem. |
22c71b1 to
81b30fa
Compare
* Rename parameter "orig_text" and don't overwrite "text". * Limit regex fuzzy match to 3-character intervening spans for performance and readability of results. * Add underscore-split match. If the underscore-split words in the text are a subset-match of the underscore-split words in the completion item, we have a candidate match. Subset-match is defined as "every word in the user's input is at least a leading substring match to at least one separated candidate word". * Add CamelCase-split match. If the CamelCase-split words in the text are a subset-match of the CamelCase-split words in the completion item, we have a match. Subset-match is defined as "every separated word in the user's input is at least a leading substring match to least on separated candidate word". * Remove unused length and position values from tuples, letting "completions" be just a list of strings. The words within the underscore and camel-split matches are not themselves fuzzy, and must be exact leading matches. Beyond that, if we need anything more fancy we should use a library rather than rolling our own.
81b30fa to
ef110d4
Compare
|
@scottnemes at the same time you were approving, I had some changes outstanding which added the leading-substring-match for underscore- and caps-separated words. Pushed those changes now. |
|
Ah, the limitation is that the candidates must also be CamelCased. |




Description
orig_textand don't overwritetext.The words within the underscore and camel-split matches are not themselves fuzzy, and must be exact matches.
It might be neat if we accepted leading substrings from all of the words instead.Done: exact matches, but leading substrings are sufficient for a match.Beyond that, if we need anything more fancy we should use a library rather than rolling our own.
This may close some open issues.
Will cause a merge conflict with #1448, to be resolved later.
Like #1448, the inspiration is to improve completions after adding more possible matches in #1447.
Example showing underscore-split match:

Checklist
changelog.md.AUTHORSfile (or it's already there).uv run ruff check && uv run ruff format && uv run mypy --install-types .to lint and format the code.