@@ -54,20 +54,26 @@ def align_rows(self, statements, look_up):
5454 continue
5555 aligned_statement = []
5656 for line in st :
57- for index , token in enumerate (line [:- 1 ]):
57+ for index , token in enumerate (line [:- 2 ]):
5858 aligned_statement .append (token )
5959 aligned_statement .append (Token (Token .SEPARATOR , (look_up [index ] - len (token .value ) + 4 ) * ' ' ))
60- aligned_statement .append (line [- 1 ])
61- aligned_statement .append (Token (Token .EOL , '\n ' )) # TODO: use global newline
60+ last_token = line [- 2 ]
61+ # remove leading whitespace before token
62+ last_token .value = last_token .value .strip () if last_token .value else last_token .value
63+ aligned_statement .append (last_token )
64+ aligned_statement .append (line [- 1 ]) # eol
6265 aligned_statements .append (Statement .from_tokens (aligned_statement ))
6366 return aligned_statements
6467
6568 def tokens_by_lines (self , node ):
6669 for index , line in enumerate (node .lines ):
67- if line and line [0 ].type == Token .VARIABLE and not line [0 ].value :
68- # if variable is prefixed with spaces
69- line = line [1 :]
70- yield [token for token in line if token .type not in ('SEPARATOR' , 'EOL' , 'EOS' )]
70+ if line :
71+ if line [0 ].type == Token .VARIABLE and not line [0 ].value :
72+ # if variable is prefixed with spaces
73+ line = line [1 :]
74+ elif line [0 ].type == Token .ARGUMENT :
75+ line [0 ].value = line [0 ].value .strip () if line [0 ].value else line [0 ].value
76+ yield [token for token in line if token .type not in ('SEPARATOR' , 'EOS' )]
7177
7278 @staticmethod
7379 def create_look_up (statements ):
0 commit comments