[gnome-builder/wip/vim] auto-indent: be smarter about indent in {|} position.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/vim] auto-indent: be smarter about indent in {|} position.
- Date: Wed, 1 Oct 2014 00:24:10 +0000 (UTC)
commit 0c0df89d98ff3e4c5a074927f3379bba8c0d74d0
Author: Christian Hergert <christian hergert me>
Date: Tue Sep 30 17:24:00 2014 -0700
auto-indent: be smarter about indent in {|} position.
src/editor/gb-source-auto-indenter-c.c | 26 +++++++++++++-------------
1 files changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/src/editor/gb-source-auto-indenter-c.c b/src/editor/gb-source-auto-indenter-c.c
index d0c1014..14b64af 100644
--- a/src/editor/gb-source-auto-indenter-c.c
+++ b/src/editor/gb-source-auto-indenter-c.c
@@ -1036,7 +1036,7 @@ line_is_label (const GtkTextIter *line)
if (*parts [i])
count++;
}
-
+
if (count > 1)
return FALSE;
@@ -1175,18 +1175,18 @@ gb_source_auto_indenter_c_format (GbSourceAutoIndenter *indenter,
str = g_string_new (NULL);
gtk_text_iter_assign (&iter, begin);
- gtk_text_iter_backward_char (&iter);
- gtk_text_iter_backward_char (&iter);
- 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);
-
- *cursor_offset = -(str->len - strlen (ret));
-
- ret = g_string_free (str, FALSE);
- g_free (tmp);
+ if (backward_find_matching_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);
+
+ *cursor_offset = -(str->len - strlen (ret));
+
+ ret = g_string_free (str, FALSE);
+ g_free (tmp);
+ }
}
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]