[gnome-builder] python: indent after beginning of empty list comprehension
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] python: indent after beginning of empty list comprehension
- Date: Sat, 10 Jan 2015 02:51:43 +0000 (UTC)
commit d8c0819aad6d6070e411c2e8c3df11b23d45b420
Author: Christian Hergert <christian hergert me>
Date: Fri Jan 9 18:45:54 2015 -0800
python: indent after beginning of empty list comprehension
var a = [
foo
^ indent to here
src/auto-indent/gb-source-auto-indenter-python.c | 33 +++++++++++++++++++++-
1 files changed, 32 insertions(+), 1 deletions(-)
---
diff --git a/src/auto-indent/gb-source-auto-indenter-python.c
b/src/auto-indent/gb-source-auto-indenter-python.c
index fc47060..043cf1e 100644
--- a/src/auto-indent/gb-source-auto-indenter-python.c
+++ b/src/auto-indent/gb-source-auto-indenter-python.c
@@ -129,6 +129,29 @@ copy_indent_minus_tab (GbSourceAutoIndenterPython *python,
}
static gboolean
+find_bracket (gunichar ch,
+ gpointer state)
+{
+ gint *count = state;
+
+ switch (ch)
+ {
+ case '[':
+ (*count)--;
+ break;
+
+ case ']':
+ (*count)++;
+ break;
+
+ default:
+ break;
+ }
+
+ return (*count) == 0;
+}
+
+static gboolean
find_paren (gunichar ch,
gpointer state)
{
@@ -188,6 +211,13 @@ indent_colon (GbSourceAutoIndenterPython *python,
switch (ch)
{
+ case ']':
+ count = 1;
+ if (!gtk_text_iter_backward_find_char (iter, find_bracket, &count,
+ NULL))
+ return NULL;
+ break;
+
case ')':
count = 1;
if (!gtk_text_iter_backward_find_char (iter, find_paren, &count,
@@ -364,7 +394,8 @@ gb_source_auto_indenter_python_format (GbSourceAutoIndenter *indenter,
switch (ch)
{
case ':':
- case '(':
+ case '(': /* Not happy about this */
+ case '[': /* Or this */
return indent_colon (python, text_view, begin, end, &iter);
case ')':
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]