diff --git a/sqlparse/filters/aligned_indent.py b/sqlparse/filters/aligned_indent.py index 553483bf..0c2653c4 100644 --- a/sqlparse/filters/aligned_indent.py +++ b/sqlparse/filters/aligned_indent.py @@ -21,8 +21,9 @@ class AlignedIndentFilter: 'UNION', 'VALUES', 'SET', 'BETWEEN', 'EXCEPT') - def __init__(self, char=' ', n='\n'): + def __init__(self, char=' ', n='\n', width=2): self.n = n + self.width = width self.offset = 0 self.indent = 0 self.char = char @@ -32,7 +33,7 @@ def nl(self, offset=1): # offset = 1 represent a single space after SELECT offset = -len(offset) if not isinstance(offset, int) else offset # add two for the space and parenthesis - indent = self.indent * (2 + self._max_kwd_len) + indent = self.indent * self.width return sql.Token(T.Whitespace, self.n + self.char * ( self._max_kwd_len + offset + indent + self.offset)) diff --git a/sqlparse/formatter.py b/sqlparse/formatter.py index 72f2c19e..0f74741e 100644 --- a/sqlparse/formatter.py +++ b/sqlparse/formatter.py @@ -182,7 +182,7 @@ def build_filter_stack(stack, options): if options.get('reindent_aligned', False): stack.enable_grouping() stack.stmtprocess.append( - filters.AlignedIndentFilter(char=options['indent_char'])) + filters.AlignedIndentFilter(width=options['indent_width'],char=options['indent_char'])) if options.get('right_margin'): stack.enable_grouping()