[geany/geany] 41122c: Always allow user filetype extensions to override system config file
Nick Treleaven
git-noreply at xxxxx
Mon Jun 10 11:15:50 UTC 2019
Branch: refs/heads/master
Author: Nick Treleaven <n at trelsoft.com>
Committer: Nick Treleaven <n at trelsoft.com>
Date: Sat, 18 May 2019 12:51:55 UTC
Commit: 41122c07bca2a45cd3750311398d42da404c85fa
https://github.com/geany/geany/commit/41122c07bca2a45cd3750311398d42da404c85fa
Log Message:
-----------
Always allow user filetype extensions to override system config file
Before the user would sometimes have to override 'UnwantedFiletype=' in
the user config file to remove an extension written in the system file.
Geany would ignore an overridden filetype in the user config file that
also matches the extension. This happened when the wanted filetype had a
higher index than the unwanted one in filetypes_array.
Modified Paths:
--------------
src/filetypes.c
src/filetypesprivate.h
Modified: src/filetypes.c
17 lines changed, 16 insertions(+), 1 deletions(-)
===================================================================
@@ -521,6 +521,7 @@ GeanyFiletype *filetypes_detect_from_extension(const gchar *utf8_filename)
{
gchar *base_filename;
GeanyFiletype *ft;
+ guint i;
ft = detect_filetype_conf_file(utf8_filename);
if (ft)
@@ -533,14 +534,27 @@ GeanyFiletype *filetypes_detect_from_extension(const gchar *utf8_filename)
SETPTR(base_filename, g_utf8_strdown(base_filename, -1));
#endif
- for (guint i = 0; i < filetypes_array->len; i++)
+ for (i = 0; i < filetypes_array->len; i++)
{
if (match_basename(filetypes[i], base_filename))
{
ft = filetypes[i];
break;
}
}
+ // check if user config overrides found ft
+ if (ft && !ft->priv->user_extensions)
+ {
+ for (i++; i < filetypes_array->len; i++)
+ {
+ if (filetypes[i]->priv->user_extensions &&
+ match_basename(filetypes[i], base_filename))
+ {
+ ft = filetypes[i];
+ break;
+ }
+ }
+ }
if (ft == NULL)
ft = filetypes[GEANY_FILETYPES_NONE];
@@ -1386,6 +1400,7 @@ static void read_extensions(GKeyFile *sysconfig, GKeyFile *userconfig)
gchar **list = g_key_file_get_string_list(
(userset) ? userconfig : sysconfig, "Extensions", filetypes[i]->name, &len, NULL);
+ filetypes[i]->priv->user_extensions = userset;
g_strfreev(filetypes[i]->pattern);
/* Note: we allow 'Foo=' to remove all patterns */
if (!list)
Modified: src/filetypesprivate.h
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -40,6 +40,7 @@ typedef struct GeanyFiletypePrivate
gboolean xml_indent_tags; /* XML tag autoindentation, for HTML and XML filetypes */
GSList *tag_files;
gboolean warn_color_scheme;
+ gboolean user_extensions; // true if extensions were read from user config file
/* TODO: move to structure in build.h and only put a pointer here */
GeanyBuildCommand *filecmds;
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list