@@ -477,10 +477,6 @@ def push(self, line, insert_into_history=True):
477
477
478
478
If the interpreter successfully runs the code, clear the buffer
479
479
"""
480
- if insert_into_history :
481
- self .insert_into_history (line )
482
- self .buffer .append (line )
483
-
484
480
if self .paste_mode :
485
481
self .saved_indent = 0
486
482
else :
@@ -493,15 +489,23 @@ def push(self, line, insert_into_history=True):
493
489
indent = max (0 , indent - self .config .tab_length )
494
490
self .saved_indent = indent
495
491
496
- logging .debug ('running %r in interpreter' , self .buffer )
497
- code_to_run = '\n ' .join (self .buffer )
498
-
499
492
#current line not added to display buffer if quitting #TODO I don't understand this comment
500
493
if self .config .syntax :
501
- self .display_buffer .append (bpythonparse (format (self .tokenize (line ), self .formatter )))
494
+ display_line = bpythonparse (format (self .tokenize (line ), self .formatter ))
495
+ # careful: self.tokenize requires that the line not be in self.buffer yet!
496
+
497
+ logging .debug ('display line being pushed to buffer: %r -> %r' , line , display_line )
498
+ self .display_buffer .append (display_line )
502
499
else :
503
500
self .display_buffer .append (fmtstr (line ))
504
501
502
+ if insert_into_history :
503
+ self .insert_into_history (line )
504
+ self .buffer .append (line )
505
+
506
+ code_to_run = '\n ' .join (self .buffer )
507
+
508
+ logging .debug ('running %r in interpreter' , self .buffer )
505
509
try :
506
510
c = bool (code .compile_command ('\n ' .join (self .buffer )))
507
511
self .saved_predicted_parse_error = False
@@ -614,6 +618,7 @@ def current_line_formatted(self):
614
618
"""The colored current line (no prompt, not wrapped)"""
615
619
if self .config .syntax :
616
620
fs = bpythonparse (format (self .tokenize (self ._current_line ), self .formatter ))
621
+ logging .debug ('Display line %r -> %r' , self ._current_line , fs )
617
622
else :
618
623
fs = fmtstr (self ._current_line )
619
624
if hasattr (self , 'old_fs' ) and str (fs ) != str (self .old_fs ):
0 commit comments