[gnome-builder/gnome-builder-3-18] clang: use match vfunc to check if we should activate
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/gnome-builder-3-18] clang: use match vfunc to check if we should activate
- Date: Tue, 13 Oct 2015 07:26:16 +0000 (UTC)
commit c24f07f61a5e4b0b38013fca23ab5a4cbd0640d9
Author: Christian Hergert <christian hergert me>
Date: Sun Sep 27 00:46:36 2015 -0700
clang: use match vfunc to check if we should activate
plugins/clang/ide-clang-completion-provider.c | 44 +++++++++++++++++++++++--
1 files changed, 41 insertions(+), 3 deletions(-)
---
diff --git a/plugins/clang/ide-clang-completion-provider.c b/plugins/clang/ide-clang-completion-provider.c
index e0ab7ed..23ba020 100644
--- a/plugins/clang/ide-clang-completion-provider.c
+++ b/plugins/clang/ide-clang-completion-provider.c
@@ -306,9 +306,6 @@ ide_clang_completion_provider_populate (GtkSourceCompletionProvider *provider,
g_assert (IDE_IS_CLANG_COMPLETION_PROVIDER (self));
- if (!g_settings_get_boolean (self->settings, "clang-autocompletion"))
- goto failure;
-
if (!gtk_source_completion_context_get_iter (context, &iter))
goto failure;
@@ -471,6 +468,46 @@ ide_clang_completion_provider_get_priority (GtkSourceCompletionProvider *provide
return IDE_CLANG_COMPLETION_PROVIDER_PRIORITY;
}
+static gboolean
+ide_clang_completion_provider_match (GtkSourceCompletionProvider *provider,
+ GtkSourceCompletionContext *context)
+{
+ IdeClangCompletionProvider *self = (IdeClangCompletionProvider *)provider;
+ GtkSourceCompletionActivation activation;
+ GtkTextIter iter;
+ GtkTextBuffer *buffer;
+ IdeFile *file;
+
+ if (!g_settings_get_boolean (self->settings, "clang-autocompletion"))
+ return FALSE;
+
+ if (gtk_source_completion_context_get_iter (context, &iter))
+ return FALSE;
+
+ buffer = gtk_text_iter_get_buffer (&iter);
+ if (!IDE_IS_BUFFER (buffer))
+ return FALSE;
+
+ file = ide_buffer_get_file (IDE_BUFFER (buffer));
+ if (file == NULL || ide_file_get_is_temporary (file))
+ return FALSE;
+
+ activation = gtk_source_completion_context_get_activation (context);
+
+ /*
+ * Do not show activation interactively if we are currently on a space.
+ */
+ 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)))
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
static void
completion_provider_iface_init (GtkSourceCompletionProviderIface *iface)
{
@@ -480,4 +517,5 @@ completion_provider_iface_init (GtkSourceCompletionProviderIface *iface)
iface->get_start_iter = ide_clang_completion_provider_get_start_iter;
iface->populate = ide_clang_completion_provider_populate;
iface->get_priority = ide_clang_completion_provider_get_priority;
+ iface->match = ide_clang_completion_provider_match;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]