A fuzzy search matching with smartcase could really add more to the program.
For instance having the following in your command history:
Typing "gvim note" would match the first, "gvimdoc" the second and third, while "gvimD" would only match the third.
This is probably too hard for me to contribute on this one. I hope this feature could raise your attention.
Thank you so much for the great work!
Upvote for this!
Created attachment 6900
Fuzzy search implementation
I've implemented fuzzy search. This patch makes filtering of results more convenient for user.
Input string is splited into two parts ("command_part" and "param_part")
- lowercase input makes search case-insensitive
- any UPPERCASE letter in "param_part" makes search case-sensitive
Usage: place patch in root of source code and run
$ patch -s -p1 < fuzzi_search.patch
Hi! Sorry it took so long to even take a brief look at the patch and try it out.
When compiling with debug full I get a build error:
appfinder-window.c: In function ‘xfce_appfinder_window_item_visible’:
appfinder-window.c:1557:25: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
gchar *filter_string= gtk_entry_get_text (GTK_ENTRY (window->entry));
Building with disable-debug masks this error, but before this can be merged I would expect you to fix it.
Other than this minor issue the patch seems to do what it promises. I'll take another look at the code itself (as you will have seen I'm not the appfinder author, I just went and released the last version of it).
Created attachment 6902
Fuzzy search implementation. All warnings are fixed now (except -Wdeprecated-declarations for gtk3 build). Please review and merge.
Thanks for reply, Simon! Please check my fixed variant of patch and merge it.
Ok, another round of review.
1. Why are you initialising succeed here?
@@ -2421,7 +2423,7 @@ xfce_appfinder_model_bookmark_toggle (XfceAppfinderModel *model,
static gsize old_len = 0;
- gboolean succeed;
+ gboolean succeed=FALSE;
Feels unrelated to the rest of the patch. Does it catch or avoid any errors that you encountered? If so, is there a separate bugreport?
In my opinion this should definitely go into a separate commit.
2. Trailing whitespace error (git tells you about that when you try to apply the patch).
3. Lots of misformatting in xfce_appfinder_model_fuzzy_match, lots of spaces missing where they should be (compare the formatting in the rest of appfinder's code, so e.g. instead of "gboolean match=FALSE;" it should be "gboolean match = FALSE;").
While this may seem trivial and nitpicky of me to mention, it really has a big impact on readability and maintenance of the code.
So out of courtesy I fixed 2. and 3. in the patch locally and removed 1. from the patch.
I will push it to master in this form. If you clarify 1. we can push that as a separate patch.
Finally, do you want to provide your real name for the patch or do you prefer if I use "neverscaired" instead?
Thanks for review!
I initialized succeed to suspress warning about uninitialized variable. It is completely minor fix and is not important. You can use "Barkov Vadim" name if want to add me to contributors. Sorry that I missed code formatting.
Pushed to master:
Thanks for the great work! Hope you'll post more patches in the future!
Sorry for dump question. Could you reopen it so I can claim a bounty for it? Thanks
Nevermind my last comment. There was a pause between closing and appearing a "claim" button. Thanks,for merging and review. Have a nice day!