[gnome-builder] clang: avoid over activating clang completion provider



commit 0eb33dbb8a41b25e7ddf03ddb3893bee61318903
Author: Christian Hergert <chergert redhat com>
Date:   Wed Nov 2 20:45:07 2016 -0700

    clang: avoid over activating clang completion provider
    
    This helps us prevent over activating in situations like right after a
    comma (,) or inside of strings/comments.

 plugins/clang/ide-clang-completion-provider.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/plugins/clang/ide-clang-completion-provider.c b/plugins/clang/ide-clang-completion-provider.c
index 26ea56a..f7787c0 100644
--- a/plugins/clang/ide-clang-completion-provider.c
+++ b/plugins/clang/ide-clang-completion-provider.c
@@ -151,9 +151,15 @@ ide_clang_completion_provider_match (GtkSourceCompletionProvider *provider,
 
   if (activation == GTK_SOURCE_COMPLETION_ACTIVATION_INTERACTIVE)
     {
-      if (gtk_text_iter_starts_line (&iter) ||
-          !gtk_text_iter_backward_char (&iter) ||
-          g_unichar_isspace (gtk_text_iter_get_char (&iter)))
+      gunichar ch;
+
+      /* avoid auto completion while in comments, strings, etc */
+      if (ide_completion_provider_context_in_comment_or_string (context))
+        return FALSE;
+
+      ch = gtk_text_iter_get_char (&iter);
+
+      if (gtk_text_iter_starts_line (&iter) || !g_unichar_isalnum (ch))
         return FALSE;
     }
 


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