diff options
author | Christian Hergert <chergert@redhat.com> | 2022-04-27 11:46:21 -0700 |
---|---|---|
committer | Christian Hergert <chergert@redhat.com> | 2022-04-27 17:37:37 -0700 |
commit | 924eb28b71e934fca31db6ef834cd583c3d43f06 (patch) | |
tree | 3eafbd34f322d25953e3730cb6625b881ba6df15 | |
parent | 6c5ed495f7beb220f3d93448a604d1498069b934 (diff) | |
download | gtksourceview-924eb28b71e934fca31db6ef834cd583c3d43f06.tar.gz |
snippets: avoid empty strings for snippets
-rw-r--r-- | gtksourceview/gtksourcesnippetbundle.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gtksourceview/gtksourcesnippetbundle.c b/gtksourceview/gtksourcesnippetbundle.c index f896b558..478f6e6e 100644 --- a/gtksourceview/gtksourcesnippetbundle.c +++ b/gtksourceview/gtksourcesnippetbundle.c @@ -255,9 +255,15 @@ elements_end_element (GMarkupParseContext *context, for (guint i = 0; state->languages[i]; i++) { - info.language = _gtk_source_snippet_manager_intern (state->manager, state->languages[i]); + char *stripped = g_strstrip (g_strdup (state->languages[i])); - gtk_source_snippet_bundle_add (state->self, &info); + if (stripped != NULL && stripped[0] != 0) + { + info.language = _gtk_source_snippet_manager_intern (state->manager, stripped); + gtk_source_snippet_bundle_add (state->self, &info); + } + + g_free (stripped); } } |