[gnome-builder] auto-indent: fix indentation with cuddled {



commit 5abf5245df4bbcbac1be791cfac6acc50ec44c51
Author: Christian Hergert <christian hergert me>
Date:   Wed Oct 15 18:22:33 2014 -0700

    auto-indent: fix indentation with cuddled {
    
    Return upon "enum {|}" will now place the } on the same column as `e'.

 src/editor/gb-source-auto-indenter-c.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/src/editor/gb-source-auto-indenter-c.c b/src/editor/gb-source-auto-indenter-c.c
index 70b9697..e52d99b 100644
--- a/src/editor/gb-source-auto-indenter-c.c
+++ b/src/editor/gb-source-auto-indenter-c.c
@@ -1178,14 +1178,17 @@ gb_source_auto_indenter_c_format (GbSourceAutoIndenter *indenter,
         GtkTextIter iter;
         GString *str;
         gchar *tmp = ret;
-        guint offset;
+        guint offset = 0;
 
         str = g_string_new (NULL);
 
         gtk_text_iter_assign (&iter, begin);
         if (backward_find_matching_char (&iter, '}'))
           {
-            offset = gtk_text_iter_get_line_offset (&iter);
+            if (line_is_whitespace_until (&iter))
+              offset = gtk_text_iter_get_line_offset (&iter);
+            else if (backward_to_line_first_char (&iter))
+              offset = gtk_text_iter_get_line_offset (&iter);
             build_indent (c, offset, &iter, str);
             g_string_prepend (str, "\n");
             g_string_prepend (str, ret);


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