File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -244,6 +244,8 @@ def add_whitespace(self, start):
244244
245245 def untokenize (self , iterable ):
246246 it = iter (iterable )
247+ indents = []
248+ startline = False
247249 for t in it :
248250 if len (t ) == 2 :
249251 self .compat (t , it )
@@ -254,6 +256,21 @@ def untokenize(self, iterable):
254256 continue
255257 if tok_type == ENDMARKER :
256258 break
259+ if tok_type == INDENT :
260+ indents .append (token )
261+ continue
262+ elif tok_type == DEDENT :
263+ indents .pop ()
264+ self .prev_row , self .prev_col = end
265+ continue
266+ elif tok_type in (NEWLINE , NL ):
267+ startline = True
268+ elif startline and indents :
269+ indent = indents [- 1 ]
270+ if start [1 ] >= len (indent ):
271+ self .tokens .append (indent )
272+ self .prev_col = len (indent )
273+ startline = False
257274 self .add_whitespace (start )
258275 self .tokens .append (token )
259276 self .prev_row , self .prev_col = end
You can’t perform that action at this time.
0 commit comments