[gnome-builder/gnome-builder-3-18] indenter-c: fix unindent of case with cuddled braces
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/gnome-builder-3-18] indenter-c: fix unindent of case with cuddled braces
- Date: Tue, 13 Oct 2015 07:37:53 +0000 (UTC)
commit fec44d0cf3ad82c20571cdc3bfd2bef000cdb32c
Author: Christian Hergert <chergert redhat com>
Date: Sat Oct 10 00:43:19 2015 -0400
indenter-c: fix unindent of case with cuddled braces
This fixes:
switch (foo) {
case foo:
^ unindent when we reach this
Previously this was broken if the bracket was not on it's own line such
as in GNU style.
plugins/c-pack/ide-c-indenter.c | 39 +++++++++++++++------------------------
1 files changed, 15 insertions(+), 24 deletions(-)
---
diff --git a/plugins/c-pack/ide-c-indenter.c b/plugins/c-pack/ide-c-indenter.c
index fa10c83..a2be5b4 100644
--- a/plugins/c-pack/ide-c-indenter.c
+++ b/plugins/c-pack/ide-c-indenter.c
@@ -1146,31 +1146,22 @@ maybe_unindent_case_label (IdeCIndenter *c,
{
if (backward_find_matching_char (&iter, '}'))
{
- if (line_is_whitespace_until (&iter))
- {
- GString *str;
- guint offset;
+ GString *str;
+ guint offset;
- str = g_string_new (NULL);
- offset = 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))
- IDE_RETURN (NULL);
- return g_string_free (str, FALSE);
- }
- else
- {
- if (backward_to_line_first_char (&iter))
- {
-#if 0
- TODO ("Deal with nested {");
-#endif
- }
- }
+ if (!line_is_whitespace_until (&iter))
+ backward_to_line_first_char (&iter);
+
+ str = g_string_new (NULL);
+ offset = 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))
+ IDE_RETURN (NULL);
+ return g_string_free (str, FALSE);
}
}
else if (line_is_label (&iter))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]