[gnome-builder] completion: use fewer <b></b> pairs
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] completion: use fewer <b></b> pairs
- Date: Fri, 2 Oct 2015 08:25:50 +0000 (UTC)
commit 15f60e0549101f29fba91e2dfa95593f37135984
Author: Christian Hergert <christian hergert me>
Date: Fri Oct 2 01:20:49 2015 -0700
completion: use fewer <b></b> pairs
This happened to be masking (mostly) a bug in GtkCellRendererText which
now has a workaround in place in GtkSourceView.
libide/ide-completion-item.c | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/libide/ide-completion-item.c b/libide/ide-completion-item.c
index bb7da76..0dbab1e 100644
--- a/libide/ide-completion-item.c
+++ b/libide/ide-completion-item.c
@@ -132,11 +132,12 @@ gchar *
ide_completion_item_fuzzy_highlight (const gchar *str,
const gchar *match)
{
- const gchar *begin = "<b>";
- const gchar *end = "</b>";
+ static const gchar *begin = "<b>";
+ static const gchar *end = "</b>";
GString *ret;
gunichar str_ch;
gunichar match_ch;
+ gboolean element_open = FALSE;
if (str == NULL || match == NULL)
return g_strdup (str);
@@ -150,18 +151,31 @@ ide_completion_item_fuzzy_highlight (const gchar *str,
if ((str_ch == match_ch) || (g_unichar_tolower (str_ch) == g_unichar_tolower (match_ch)))
{
- g_string_append (ret, begin);
+ if (!element_open)
+ {
+ g_string_append (ret, begin);
+ element_open = TRUE;
+ }
+
g_string_append_unichar (ret, str_ch);
- g_string_append (ret, end);
/* TODO: We could seek to the next char and append in a batch. */
match = g_utf8_next_char (match);
}
else
{
+ if (element_open)
+ {
+ g_string_append (ret, end);
+ element_open = FALSE;
+ }
+
g_string_append_unichar (ret, str_ch);
}
}
+ if (element_open)
+ g_string_append (ret, end);
+
return g_string_free (ret, FALSE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]