[gnome-builder] io: Ignore case for content type matching by prefix



commit d2c1a3e3adbdfa468c57d68d5ad64b1fce5e3ba1
Author: vanadiae <vanadiae35 gmail com>
Date:   Thu Dec 31 15:53:58 2020 +0100

    io: Ignore case for content type matching by prefix
    
    This makes it more resilient to file names like Readme.txt, or any file
    which isn't fully upper-cased.

 src/libide/io/ide-content-type.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/src/libide/io/ide-content-type.c b/src/libide/io/ide-content-type.c
index 6a76f0ea3..94ac6b116 100644
--- a/src/libide/io/ide-content-type.c
+++ b/src/libide/io/ide-content-type.c
@@ -142,7 +142,10 @@ ide_g_content_type_get_symbolic_icon (const gchar *content_type,
         {
           for (guint j = 0; j < G_N_ELEMENTS (bundled_check_by_name_prefix); j++)
             {
-              if (g_str_has_prefix (filename, bundled_check_by_name_prefix[j].searched_prefix))
+              const gchar *searched_prefix = bundled_check_by_name_prefix[j].searched_prefix;
+
+              /* Check prefix but ignore case, because there might be some files named e.g. ReadMe.txt */
+              if (g_ascii_strncasecmp (filename, searched_prefix, strlen (searched_prefix)) == 0)
                 return g_icon_new_for_string (bundled_check_by_name_prefix[j].icon_name, NULL);
             }
         }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]