[gnome-builder] auto-indent-xml: place closing tag on new line when indenting



commit 15e35d98206f77ef7d74319ad4b3a931d2f2a6dc
Author: Christian Hergert <christian hergert me>
Date:   Wed Jan 7 01:25:20 2015 -0800

    auto-indent-xml: place closing tag on new line when indenting

 src/auto-indent/gb-source-auto-indenter-xml.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/src/auto-indent/gb-source-auto-indenter-xml.c b/src/auto-indent/gb-source-auto-indenter-xml.c
index 2e75d95..4406c12 100644
--- a/src/auto-indent/gb-source-auto-indenter-xml.c
+++ b/src/auto-indent/gb-source-auto-indenter-xml.c
@@ -22,6 +22,7 @@
 
 #include "gb-log.h"
 #include "gb-source-auto-indenter-xml.h"
+#include "gb-gtk.h"
 
 /*
  * TODO:
@@ -191,6 +192,27 @@ gb_source_auto_indenter_xml_indent (GbSourceAutoIndenterXml *xml,
     {
       offset = gtk_text_iter_get_line_offset (&match_begin);
       build_indent (xml, offset + INDENT_WIDTH, &match_begin, str);
+
+      /*
+       * If immediately after our cursor is a closing tag, we will move it to
+       * a line after our indent line.
+       */
+      if ('<' == gtk_text_iter_get_char (end) &&
+          '/' == gb_gtk_text_iter_get_next_char (end))
+        {
+          GString *str2;
+
+          str2 = g_string_new (NULL);
+          build_indent (xml, offset, &match_begin, str2);
+
+          g_string_append (str, "\n");
+          g_string_append (str, str2->str);
+
+          *cursor_offset = -str2->len - 1;
+
+          g_string_free (str2, TRUE);
+        }
+
       GOTO (cleanup);
     }
 


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