[gnome-builder] python: add indentation rule for parameter lists



commit b56cd0fd64685eb50a8cacf4f218295212aec8d3
Author: Christian Hergert <christian hergert me>
Date:   Sat Oct 3 14:37:28 2015 -0700

    python: add indentation rule for parameter lists

 plugins/python-pack/python_indenter.py |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/plugins/python-pack/python_indenter.py b/plugins/python-pack/python_indenter.py
index dfc2580..9c86c20 100644
--- a/plugins/python-pack/python_indenter.py
+++ b/plugins/python-pack/python_indenter.py
@@ -419,6 +419,7 @@ class Discoveries:
         return children
 
 class PythonSettings:
+    align_params = True
     indent_width = 4
     insert_spaces = True
 
@@ -472,6 +473,14 @@ class PythonIndenter(GObject.Object): #, Ide.Indenter):
         if nearest.rank == Rank.COMMENT:
             return self.copy_indent(view, iter, suffix='# ')
 
+        if self.settings.align_params \
+        and discoveries.select_tail(Rank.FUNCTION, Rank.TUPLE):
+            # indent for the tuple begin position plus a space to move
+            # after the opening (. Try to copy as much of the previous
+            # line as we can to preserve indentation.
+            indent = self.get_indent_at_visual_column(nearest.column+1, iter)
+            return '\n' + indent, 0
+
         iter = begin.copy()
         iter.set_line(nearest.line)
         return self.copy_indent(view, iter, extra=1)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]