[gnome-builder] auto-indent: use a copied iter to avoid mutation



commit 2902d6617d97f746b916466242f91caf9a005b33
Author: Christian Hergert <christian hergert me>
Date:   Thu Oct 16 18:52:04 2014 -0700

    auto-indent: use a copied iter to avoid mutation

 src/auto-indent/gb-source-auto-indenter-c.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/auto-indent/gb-source-auto-indenter-c.c b/src/auto-indent/gb-source-auto-indenter-c.c
index 8c7e1c7..ef278eb 100644
--- a/src/auto-indent/gb-source-auto-indenter-c.c
+++ b/src/auto-indent/gb-source-auto-indenter-c.c
@@ -318,8 +318,13 @@ backward_find_matching_char (GtkTextIter *iter,
         }
       else if ((cur == '/') && iter_ends_c89_comment (iter))
         {
-          if (!backward_before_c89_comment (iter))
-            break;
+          GtkTextIter tmp = *iter;
+
+          if (backward_before_c89_comment (&tmp))
+            {
+              *iter = tmp;
+              cur = gtk_text_iter_get_char (iter);
+            }
         }
 
       if (cur == match)


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