From 794b18df343c6e5a5d1625b7df65682defa1be73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 3 Oct 2023 12:58:40 +0200 Subject: [PATCH] gdesktopappinfo: Do not search Comment field The Comment field provides a user-visible description of the app, which usually contains generic words ("and", "or", "not", "is", ...) that add noise when used for search. It made some sense to match against the field as a fallback for Keywords, before that key was well established. However that key has been around for years now, so hopefully every app where additional terms are helpful uses it by now. With that, the downside of added noise outweighs the benefit, so it's time to stop matching on comments. --- gio/gdesktopappinfo.c | 6 +----- gio/tests/desktop-app-info.c | 18 +++++++----------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c index f724ec9fc..eaaf79273 100644 --- a/gio/gdesktopappinfo.c +++ b/gio/gdesktopappinfo.c @@ -432,7 +432,6 @@ add_to_table_if_appropriate (GHashTable *apps, enum { - DESKTOP_KEY_Comment, DESKTOP_KEY_Exec, DESKTOP_KEY_GenericName, DESKTOP_KEY_Keywords, @@ -452,8 +451,7 @@ const gchar desktop_key_match_category[N_DESKTOP_KEYS] = { [DESKTOP_KEY_Exec] = 2, [DESKTOP_KEY_Keywords] = 3, [DESKTOP_KEY_GenericName] = 4, - [DESKTOP_KEY_X_GNOME_FullName] = 5, - [DESKTOP_KEY_Comment] = 6 + [DESKTOP_KEY_X_GNOME_FullName] = 5 }; typedef enum { @@ -487,8 +485,6 @@ desktop_key_get_name (guint key_id) { switch (key_id) { - case DESKTOP_KEY_Comment: - return "Comment"; case DESKTOP_KEY_Exec: return "Exec"; case DESKTOP_KEY_GenericName: diff --git a/gio/tests/desktop-app-info.c b/gio/tests/desktop-app-info.c index 6b4580893..bd28f940e 100644 --- a/gio/tests/desktop-app-info.c +++ b/gio/tests/desktop-app-info.c @@ -881,11 +881,10 @@ test_search (void) assert_search ("frobni", "frobnicator.desktop\n", TRUE, FALSE, NULL, NULL); /* Obvious multi-word search */ - assert_search ("gno hel", "yelp.desktop\n", TRUE, TRUE, NULL, NULL); + assert_search ("doc hel", "yelp.desktop\n", TRUE, TRUE, NULL, NULL); /* Repeated search terms should do nothing... */ - assert_search ("files file fil fi f", "nautilus.desktop\n" - "gedit.desktop\n", TRUE, TRUE, NULL, NULL); + assert_search ("files file fil fi f", "nautilus.desktop\n", TRUE, TRUE, NULL, NULL); /* "con" will match "connect" and "contacts" on name with prefix match in * first group, then second group is a Keyword prefix match for "configuration" in dconf-editor.desktop @@ -896,12 +895,10 @@ test_search (void) "nautilus-classic.desktop\n", TRUE, TRUE, NULL, NULL); /* "gnome" will match "eye of gnome" from the user's directory, plus - * matching "GNOME Clocks" X-GNOME-FullName. It's only a comment on - * yelp and gnome-contacts, though. + * matching "GNOME Clocks" X-GNOME-FullName. */ assert_search ("gnome", "eog.desktop\n" - "org.gnome.clocks.desktop\n" - "yelp.desktop gnome-contacts.desktop\n", TRUE, TRUE, NULL, NULL); + "org.gnome.clocks.desktop\n", TRUE, TRUE, NULL, NULL); /* eog has exec name 'false' in usr only */ assert_search ("false", "eog.desktop\n", TRUE, FALSE, NULL, NULL); @@ -913,9 +910,9 @@ test_search (void) assert_search ("nonsearchable", "", TRUE, FALSE, NULL, NULL); /* "gnome con" will match only gnome contacts; via the name for - * "contacts" and the comment for "gnome" + * "contacts" and keywords for "friend" */ - assert_search ("gnome con", "gnome-contacts.desktop\n", TRUE, TRUE, NULL, NULL); + assert_search ("friend con", "gnome-contacts.desktop\n", TRUE, TRUE, NULL, NULL); /* make sure we get the correct kde4- prefix on the application IDs * from subdirectories @@ -938,8 +935,7 @@ test_search (void) /* make sure localised searching works properly */ assert_search ("foliumi", "nautilus.desktop\n" - "kde4-konqbrowser.desktop\n" - "eog.desktop\n", TRUE, FALSE, "en_US.UTF-8", "eo"); + "kde4-konqbrowser.desktop\n", TRUE, FALSE, "en_US.UTF-8", "eo"); /* the user's eog.desktop has no translations... */ assert_search ("foliumi", "nautilus.desktop\n" "kde4-konqbrowser.desktop\n", TRUE, TRUE, "en_US.UTF-8", "eo");