[gnome-builder] auto-indent: unindent case foo: to switch scope.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] auto-indent: unindent case foo: to switch scope.
- Date: Sun, 21 Sep 2014 05:21:13 +0000 (UTC)
commit 9f2998eb2c85078354cb84d28ba09c72ca35015d
Author: Christian Hergert <christian hergert me>
Date: Sat Sep 20 22:21:02 2014 -0700
auto-indent: unindent case foo: to switch scope.
src/editor/gb-source-auto-indenter-c.c | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/src/editor/gb-source-auto-indenter-c.c b/src/editor/gb-source-auto-indenter-c.c
index 064070d..2733035 100644
--- a/src/editor/gb-source-auto-indenter-c.c
+++ b/src/editor/gb-source-auto-indenter-c.c
@@ -1020,6 +1020,33 @@ maybe_unindent_case_label (GbSourceAutoIndenterC *c,
if (line_is_case (&iter))
{
TODO ("Implement unindent for case");
+
+ if (backward_find_matching_char (&iter, '}'))
+ {
+ if (line_is_whitespace_until (&iter))
+ {
+ GString *str;
+ guint offset;
+
+ str = g_string_new (NULL);
+ offset = gtk_text_iter_get_line_offset (&iter);
+ build_indent (c, offset, &iter, str);
+ while (!gtk_text_iter_starts_line (begin))
+ gtk_text_iter_backward_char (begin);
+ gtk_text_iter_assign (end, begin);
+ while (g_unichar_isspace (gtk_text_iter_get_char (end)))
+ if (!gtk_text_iter_forward_char (end))
+ RETURN (NULL);
+ return g_string_free (str, FALSE);
+ }
+ else
+ {
+ if (backward_to_line_first_char (&iter))
+ {
+ TODO ("Deal with nested {");
+ }
+ }
+ }
}
else if (line_is_label (&iter))
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]