[gnome-builder] python: copy previous line in parameter lists unless we see opening paren
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] python: copy previous line in parameter lists unless we see opening paren
- Date: Thu, 8 Jan 2015 11:56:15 +0000 (UTC)
commit 28f7a1fdfb205ce870266bd803a70e698efa0441
Author: Christian Hergert <christian hergert me>
Date: Thu Jan 8 03:56:10 2015 -0800
python: copy previous line in parameter lists unless we see opening paren
src/auto-indent/gb-source-auto-indenter-python.c | 24 +++++++++++++++++++--
1 files changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/src/auto-indent/gb-source-auto-indenter-python.c
b/src/auto-indent/gb-source-auto-indenter-python.c
index 09e3fe0..5dde210 100644
--- a/src/auto-indent/gb-source-auto-indenter-python.c
+++ b/src/auto-indent/gb-source-auto-indenter-python.c
@@ -235,11 +235,18 @@ indent_parens (GbSourceAutoIndenterPython *python,
GtkTextIter *end,
GtkTextIter *iter)
{
+ GtkTextIter copy;
+ GString *str;
gint count = 1;
- if (gtk_text_iter_backward_find_char (iter, find_paren, &count, NULL))
+ copy = *iter;
+
+ /* if we come across an opening paren on this line, we will move 1 space
+ * past it. otherwise, just copy the previous line's indentation.
+ */
+ if (gtk_text_iter_backward_find_char (iter, find_paren, &count, NULL) &&
+ (gtk_text_iter_get_line (iter) == gtk_text_iter_get_line (©)))
{
- GString *str;
guint offset;
gint i;
@@ -251,7 +258,18 @@ indent_parens (GbSourceAutoIndenterPython *python,
return g_string_free (str, FALSE);
}
- return NULL;
+ str = g_string_new (NULL);
+
+ gtk_text_iter_set_line_offset (©, 0);
+
+ while (g_unichar_isspace (gtk_text_iter_get_char (©)))
+ {
+ g_string_append (str, " ");
+ if (!gtk_text_iter_forward_char (©))
+ break;
+ }
+
+ return g_string_free (str, FALSE);
}
static gchar *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]