Sublime Forum

Why on_query_completions doesn't support fuzzy matching

#1

The doc I read is here.

If the prefix is bex and on_query_completions returns ['beat', 'bear', 'bean'], the completion list won’t be shown. I think this is weird. 'beat', 'bear', 'bean' is the fuzzy matching of bex, so Sublime should show what I return to it and shouldn’t filter the result.

0 Likes

#2

The only thing on_query_completions is asked for are candidates to possibly show. The handler can use prefix to limit amount of returned values. Fuzzy matching is not within scope of such a handler as several completion sources (plugins, sublime-completions, sublime-snippets) need to be queried and merged. That’s what core is dooing then. Number of matches which are finally displayed in completions panel has been limited in ST4 to maintain performance. You might need to hit ctrl+space at some point to retrigger completions update.

That said, as a fuzzy noop, I still wonder how bex matches beat or bear as none of them contains x.

0 Likes

#3
I still wonder how bex matches beat or bear as none of them contains x.

Ah yes :sweat_smile: You are right.
This example is from the perspective of edit distance but I didn’t realize that the candidate word has to contain each character in prefix. After taking into account this point, I think the behavior is acceptable. Thanks for your detailed explanation. @deathaxe

0 Likes