[gnome-builder/gnome-builder-3-18] libide: only replay results if we have symbol characters



commit 1d29723628afa1facb13803da137f6682ee60f74
Author: Christian Hergert <christian hergert me>
Date:   Thu Oct 1 19:41:56 2015 -0700

    libide: only replay results if we have symbol characters
    
    We only use this for symbols right now, so safe to put this check here.
    
    The gist is this, if we have a character like ( or [ or {, our result
    set would not take that into account. So callers need to generate a new
    list. We simply limit this to "symbol chars" which are alpha numeric
    today. Theoretically, we might need to support ? and ! at some point,
    but those are always suffixes and require us to change the result set
    anyway.

 libide/ide-completion-results.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-completion-results.c b/libide/ide-completion-results.c
index 7e145b5..ac1e210 100644
--- a/libide/ide-completion-results.c
+++ b/libide/ide-completion-results.c
@@ -185,6 +185,22 @@ ide_completion_results_replay (IdeCompletionResults *self,
 
   if (g_str_has_prefix (query, priv->query))
     {
+      const gchar *suffix = query + strlen (priv->query);
+
+      /*
+       * Only allow completing using this result set if we have characters
+       * that could continue a function name, etc. In all the languages we
+       * support this is alpha-numeric only. We could potentially turn this
+       * into a vfunc if we need to support something other than that.
+       */
+      for (; *suffix; suffix = g_utf8_next_char (suffix))
+        {
+          gunichar ch = g_utf8_get_char (suffix);
+          if (G_LIKELY (ch == '_' || g_unichar_isalnum (ch)))
+            continue;
+          IDE_RETURN (FALSE);
+        }
+
       priv->can_reuse_list = (priv->replay != NULL && g_str_has_prefix (query, priv->replay));
       priv->needs_refilter = TRUE;
       priv->needs_sort = TRUE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]