Open tconbeer opened 1 month ago
Hey @tconbeer - this program is awesome! thanks for making it!
I'm really keen to have fuzzy-matching, i often don't know what column names are in my database, so i rely on fuzzy matching (in tools like dbeaver) to get them for me.
Would it be as simple as changing the line here for what constitutes a matched completion option? https://github.com/tconbeer/harlequin/blob/main/src/harlequin/autocomplete/completers.py#L52
I'd imagine, for fuzzy matching, everything would have a "score" which you could threshold.. or maybe, you'd just sort all options by the score (so that the list will be everything but the most likely options are near the top)
This could be quite slow in straight python... do you have any rules / guidelines for adding in C libs into the application? FZF comes to mind.
This might turn out to be a simple change, that I can have a look at doing if you would like.. I'm not sure what the difference between word and member completion classes are though 😅
Yes, you're on the right track there. To answer your questions:
WordCompleter
is called when you start typing any word character in the editor. It matches any keyword, db object, etc. The MemberCompleter
is called when you type .
(and any subsequent word characters); it returns matches that are members of a certain parent context (e.g., column names if the parent is a table). Both would likely benefit from fuzzy-matching, possibly with some different config. (There is also a PathCompleter
but that's probably out of scope). self._query_regex = compile(
".{0,5}?".join(f"({escape(character)})" for character in query),
flags=0 if case_sensitive else IGNORECASE,
)
ESPECIALLY for member autocomplete (fuzzy-matching table and column names, etc.).