[gnome-builder/auto-indent] auto-indent: handle ", " in enum list with cuddled {



commit a0448a6b7c21a2a324ec27ed0ac87f21d166573c
Author: Christian Hergert <christian hergert me>
Date:   Thu Sep 18 16:32:52 2014 -0700

    auto-indent: handle "," in enum list with cuddled {
    
    enum {
      FOO_ITEM,
      <cursor>

 src/editor/gb-source-auto-indenter-c.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/src/editor/gb-source-auto-indenter-c.c b/src/editor/gb-source-auto-indenter-c.c
index 4144e8f..90eebcf 100644
--- a/src/editor/gb-source-auto-indenter-c.c
+++ b/src/editor/gb-source-auto-indenter-c.c
@@ -385,7 +385,15 @@ gb_source_auto_indenter_c_indent (GbSourceAutoIndenterC *c,
       if (gtk_text_iter_get_char (iter) == '(')
         offset++;
       else if (gtk_text_iter_get_char (iter) == '{')
-        offset += priv->scope_indent;
+        {
+          /*
+           * Handle the case where { is not the first character,
+           * like "enum {".
+           */
+          if (backward_to_line_first_char (iter))
+            offset = gtk_text_iter_get_line_offset (iter);
+          offset += priv->scope_indent;
+        }
 
       build_indent (c, offset, iter, str);
       GOTO (cleanup);


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