! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Fuzzy search matching
Status:
RESOLVED: FIXED
Severity:
enhancement
Product:
Xfce4-appfinder
Component:
General

Comments

Description elmanuelito 2013-10-07 11:15:37 CEST
Hi 

A fuzzy search matching with smartcase could really add more to the program. 

For instance having the following in your command history:
gvim ~/folder/notes
gvim /usr/doc
gvim /usr/Doc

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!
Comment 1 Antti Ahti 2016-09-21 09:05:13 CEST
Upvote for this!
Comment 2 neverscaired 2016-11-12 03:30:15 CET
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")
General points:
- 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
Comment 3 Simon Steinbeiss editbugs 2016-11-18 01:29:33 CET
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).

Good work!
Comment 4 neverscaired 2016-11-19 01:59:35 CET
Created attachment 6902 
Fuzzy search

Fuzzy search implementation. All warnings are fixed now (except -Wdeprecated-declarations for gtk3 build). Please review and merge.
Comment 5 neverscaired 2016-11-19 02:00:52 CET
Thanks for reply, Simon! Please check my fixed variant of patch and merge it.
Comment 6 Simon Steinbeiss editbugs 2016-11-22 20:38:28 CET
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;
   GString      *contents;
   gchar        *filename;
-  gboolean      succeed;
+  gboolean      succeed=FALSE;
   GtkTreePath  *path;
   gint          idx;
   GtkTreeIter   iter;


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?
Comment 7 neverscaired 2016-11-23 19:02:24 CET
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.
Comment 8 Simon Steinbeiss editbugs 2016-11-23 23:19:52 CET
Pushed to master:
https://git.xfce.org/xfce/xfce4-appfinder/commit/?id=486a9ae055d3e4b8baf5c5648587b42535365185

Thanks for the great work! Hope you'll post more patches in the future!
Comment 9 neverscaired 2016-11-24 16:08:41 CET
Sorry for dump question. Could you reopen it so I can claim a bounty for it? Thanks
Comment 10 neverscaired 2016-11-24 16:19:07 CET
Nevermind my last comment. There was a pause between closing and appearing a "claim" button. Thanks,for merging and review. Have a nice day!

Bug #10393

Reported by:
elmanuelito
Reported on: 2013-10-07
Last modified on: 2017-05-28

People

Assignee:
Simon Steinbeiss
CC List:
3 users

Version

Version:
4.12.0

Attachments

Fuzzy search implementation (4.45 KB, patch)
2016-11-12 03:30 CET , neverscaired
no flags
Fuzzy search (4.92 KB, patch)
2016-11-19 01:59 CET , neverscaired
ochosi : review+

Additional information