[gcalctool/vala] Fix ans detection



commit 82e0f02179905a03d3c8e1fb1382c827ccba2f71
Author: Robert Ancell <robert ancell canonical com>
Date:   Fri Oct 12 21:27:01 2012 +1300

    Fix ans detection

 src/math-equation.vala |   15 +++------------
 1 files changed, 3 insertions(+), 12 deletions(-)
---
diff --git a/src/math-equation.vala b/src/math-equation.vala
index 6caf1be..2b54ec4 100644
--- a/src/math-equation.vala
+++ b/src/math-equation.vala
@@ -622,6 +622,8 @@ public class MathEquation : Gtk.TextBuffer
         var ans_start = -1, ans_end = -1;
         if (ans_start_mark != null)
             get_ans_offsets (out ans_start, out ans_end);
+        if (ans_start >= 0)
+            text = text.substring (0, ans_start) + "ans" + text.substring (ans_end);
 
         var last_is_digit = false;
         var index = 0;
@@ -635,15 +637,6 @@ public class MathEquation : Gtk.TextBuffer
             if (text.get_next_char (ref i, out next_char))
                 next_is_digit = next_char.isdigit ();
 
-            /* Replace ans text with variable */
-            if (index == ans_start)
-            {
-                 eq_text += "ans";
-                 index += ans_end - ans_start - 1;
-                 is_digit = false;
-                 continue;
-            }
-
             /* Ignore thousands separators */
             if (c == serializer.get_thousands_separator () && last_is_digit && next_is_digit)
                 ;
@@ -656,9 +649,7 @@ public class MathEquation : Gtk.TextBuffer
             last_is_digit = is_digit;
         }
 
-        text = eq_text;
-
-        return text;
+        return eq_text;
     }
 
     public Number? get_number ()



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