Commit 559a94bf authored by Daniel Buch Hansen's avatar Daniel Buch Hansen

ide-langserv-hover: fix MarkedString

parent 70997144
Pipeline #38538 passed with stage
in 24 minutes and 38 seconds
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment