[latexila] Completion: use string.get_prev_char() (continued)



commit 13f50c03979995450fb837acae8e5b8f09204afa
Author: SÃbastien Wilmet <swilmet src gnome org>
Date:   Wed Jul 18 22:59:52 2012 +0200

    Completion: use string.get_prev_char() (continued)
    
    In get_latex_command_at_index().

 src/completion.vala |   17 ++---------------
 1 files changed, 2 insertions(+), 15 deletions(-)
---
diff --git a/src/completion.vala b/src/completion.vala
index 30647a2..5dee00e 100644
--- a/src/completion.vala
+++ b/src/completion.vala
@@ -514,18 +514,10 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
     {
         return_val_if_fail (index <= text.length, null);
 
-        // Skip the last character (the '{' in the above example).
         int cur_index = index;
-        if (! Utils.string_get_prev_char (text, ref cur_index, null))
-            return null;
-
-        while (true)
+        unichar cur_char;
+        while (text.get_prev_char (ref cur_index, out cur_char))
         {
-            unichar cur_char;
-            int prev_index = cur_index;
-            bool first_char = ! Utils.string_get_prev_char (text,
-                ref prev_index, out cur_char);
-
             if (cur_char == '\\')
             {
                 // If the backslash is escaped, it's not a LaTeX command.
@@ -538,11 +530,6 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
             // A LaTeX command contains only normal letters and '*'.
             if (! cur_char.isalpha () && cur_char != '*')
                 break;
-
-            if (first_char)
-                break;
-
-            cur_index = prev_index;
         }
 
         return null;



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