[latexila] Completion: more robust code wrt CompletionContexts



commit 482a94936cf363ac9246e00b1d12b632aab2e42c
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Mon Oct 13 15:50:37 2014 +0200

    Completion: more robust code wrt CompletionContexts
    
    GtkSourceView 3.15.1 (currently git master) is required.

 configure.ac        |    2 +-
 src/completion.vala |   13 +++++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index adf1bc6..b1dd21f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -27,7 +27,7 @@ LT_INIT
 # Update also the --target-glib option in src/Makefile.am.
 GLIB_REQUIRED_VERSION="2.40"
 GTK_REQUIRED_VERSION="3.14"
-GTKSOURCEVIEW_REQUIRED_VERSION="3.10"
+GTKSOURCEVIEW_REQUIRED_VERSION="3.15.1"
 GTKSPELL_REQUIRED_VERSION="3.0.4"
 VALA_REQUIRED_VERSION="0.25.4"
 GEE_REQUIRED_VERSION="0.10"
diff --git a/src/completion.vala b/src/completion.vala
index 677766e..9e5878a 100644
--- a/src/completion.vala
+++ b/src/completion.vala
@@ -117,7 +117,10 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
 
     public bool match (SourceCompletionContext context)
     {
-        TextIter iter = context.get_iter ();
+        TextIter iter;
+
+        if (!context.get_iter (out iter))
+            return false;
 
         // if text selected, NO completion
         TextBuffer buf = iter.get_buffer ();
@@ -161,7 +164,13 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
 
     public void populate (SourceCompletionContext context)
     {
-        TextIter iter = context.get_iter ();
+        TextIter iter;
+
+        if (!context.get_iter (out iter))
+        {
+            show_no_proposals (context);
+            return;
+        }
 
         // Is the cursor in a command name?
         string? cmd = get_latex_command_at_iter (iter);


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