From d346fa6b7ea01a8946fac07e8034a55becfa15a0 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 17 Sep 2019 14:32:07 -0400 Subject: [PATCH] Avoid suggesting titles The commands array contains entries that serve just as section titles; avoid returning those when looking for misspelt commands. Pointed out in https://github.com/flatpak/flatpak/issues/3040 Closes: #3107 Approved by: matthiasclasen --- app/flatpak-main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/flatpak-main.c b/app/flatpak-main.c index 20c575a5..ff0ab07e 100644 --- a/app/flatpak-main.c +++ b/app/flatpak-main.c @@ -534,10 +534,13 @@ find_similar_command (const char *word, GOptionEntry *entries[3] = { global_entries, empty_entries, user_entries }; d = G_MAXINT; - suggestion = commands[0].name; + suggestion = NULL; for (i = 0; commands[i].name; i++) { + if (!commands[i].fn) + continue; + int d1 = flatpak_levenshtein_distance (word, commands[i].name); if (d1 < d) {