[gnome-builder] libide: avoid querying for results when no words are available
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide: avoid querying for results when no words are available
- Date: Tue, 24 Mar 2015 00:21:57 +0000 (UTC)
commit 4a1ff68dd80ba34202564c95f1821a0fac92f7e3
Author: Christian Hergert <christian hergert me>
Date: Mon Mar 16 03:06:45 2015 -0700
libide: avoid querying for results when no words are available
libide/clang/ide-clang-completion-provider.c | 24 +++++++++++++++---------
1 files changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/libide/clang/ide-clang-completion-provider.c b/libide/clang/ide-clang-completion-provider.c
index e0f0ccf..d96d384 100644
--- a/libide/clang/ide-clang-completion-provider.c
+++ b/libide/clang/ide-clang-completion-provider.c
@@ -269,6 +269,7 @@ ide_clang_completion_provider_populate (GtkSourceCompletionProvider *provider,
AddProposalsState *state;
IdeClangService *service;
GtkSourceCompletion *completion;
+ g_autofree gchar *word = NULL;
GtkSourceView *view;
GtkTextBuffer *buffer;
IdeContext *icontext;
@@ -280,19 +281,24 @@ ide_clang_completion_provider_populate (GtkSourceCompletionProvider *provider,
if (!gtk_source_completion_context_get_iter (context, &iter))
goto failure;
- buffer = gtk_text_iter_get_buffer (&iter);
- if (buffer == NULL)
+ word = get_word (&iter);
+ if (!word || !word [0] || !word [1])
goto failure;
+
+ buffer = gtk_text_iter_get_buffer (&iter);
g_assert (IDE_IS_BUFFER (buffer));
/* stash the view for later */
- g_object_get (context, "completion", &completion, NULL);
- g_assert (GTK_SOURCE_IS_COMPLETION (completion));
- view = gtk_source_completion_get_view (completion);
- g_assert (IDE_IS_SOURCE_VIEW (view));
- g_assert ((self->view == NULL) || (self->view == (IdeSourceView *)view));
- self->view = IDE_SOURCE_VIEW (view);
- g_clear_object (&completion);
+ if (G_UNLIKELY (!self->view))
+ {
+ g_object_get (context, "completion", &completion, NULL);
+ g_assert (GTK_SOURCE_IS_COMPLETION (completion));
+ view = gtk_source_completion_get_view (completion);
+ g_assert (IDE_IS_SOURCE_VIEW (view));
+ g_assert ((self->view == NULL) || (self->view == (IdeSourceView *)view));
+ self->view = IDE_SOURCE_VIEW (view);
+ g_clear_object (&completion);
+ }
file = ide_buffer_get_file (IDE_BUFFER (buffer));
if (file == NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]