[gnome-builder] ide-langserv-hover: fix MarkedString
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] ide-langserv-hover: fix MarkedString
- Date: Thu, 1 Nov 2018 20:21:35 +0000 (UTC)
commit 559a94bf03e20c63fddb24c133f4db2ebd072563
Author: Daniel Buch <boogiewasthere gmail com>
Date: Thu Nov 1 16:24:27 2018 +0100
ide-langserv-hover: fix MarkedString
src/libide/langserv/ide-langserv-hover-provider.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/src/libide/langserv/ide-langserv-hover-provider.c
b/src/libide/langserv/ide-langserv-hover-provider.c
index b4573041e..5e5db3bc6 100644
--- a/src/libide/langserv/ide-langserv-hover-provider.c
+++ b/src/libide/langserv/ide-langserv-hover-provider.c
@@ -74,7 +74,7 @@ static GParamSpec *properties [N_PROPS];
static IdeMarkedContent *
parse_marked_string (GVariant *v)
{
- g_autoptr(GString) str = g_string_new (NULL);
+ g_autoptr(GString) gstr = g_string_new (NULL);
g_autoptr(GVariant) child = NULL;
GVariant *item;
GVariantIter iter;
@@ -87,6 +87,17 @@ parse_marked_string (GVariant *v)
* MarkedString is (string | { language: string, value: string })
*/
+ if (g_variant_is_of_type (v, G_VARIANT_TYPE_STRING))
+ {
+ gsize len = 0;
+ const gchar *str = g_variant_get_string (v, &len);
+
+ if (str && *str == '\0')
+ return NULL;
+
+ return ide_marked_content_new_from_data (str, len, IDE_MARKED_KIND_PLAINTEXT);
+ }
+
if (g_variant_is_of_type (v, G_VARIANT_TYPE_VARIANT))
v = child = g_variant_get_variant (v);
@@ -101,7 +112,7 @@ parse_marked_string (GVariant *v)
asv = child2 = g_variant_get_variant (item);
if (g_variant_is_of_type (asv, G_VARIANT_TYPE_STRING))
- g_string_append (str, g_variant_get_string (asv, NULL));
+ g_string_append (gstr, g_variant_get_string (asv, NULL));
else if (g_variant_is_of_type (asv, G_VARIANT_TYPE_VARDICT))
{
const gchar *lang = "";
@@ -117,15 +128,15 @@ parse_marked_string (GVariant *v)
g_string_append (str, value);
#else
if (!dzl_str_empty0 (value))
- g_string_append_printf (str, "```\n%s\n```", value);
+ g_string_append_printf (gstr, "```\n%s\n```", value);
#endif
}
g_variant_unref (item);
}
- if (str->len)
- return ide_marked_content_new_from_data (str->str, str->len, IDE_MARKED_KIND_MARKDOWN);
+ if (gstr->len)
+ return ide_marked_content_new_from_data (gstr->str, gstr->len, IDE_MARKED_KIND_MARKDOWN);
return NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]