@@ -297,14 +297,14 @@ def process_event(self, e):
297297 self .add_normal_character (e if len (e ) == 1 else e [- 1 ]) #strip control seq
298298 self .update_completion ()
299299
300- def on_enter (self ):
300+ def on_enter (self , insert_into_history = True ):
301301 self .cursor_offset_in_line = - 1 # so the cursor isn't touching a paren
302302 self .unhighlight_paren () # in unhighlight_paren
303303
304304 self .rl_history .append (self ._current_line )
305305 self .rl_history .last ()
306306 self .history .append (self ._current_line )
307- self .push (self ._current_line )
307+ self .push (self ._current_line , insert_into_history = insert_into_history )
308308
309309 def on_finish_running_code (self , output , error , done , indent ):
310310 if output :
@@ -393,12 +393,13 @@ def update_completion(self, tab=False):
393393 if self .config .auto_display_list or tab :
394394 self .list_win_visible = BpythonRepl .complete (self , tab )
395395
396- def push (self , line ):
396+ def push (self , line , insert_into_history = True ):
397397 """Push a line of code onto the buffer, run the buffer
398398
399399 If the interpreter successfully runs the code, clear the buffer
400400 """
401- self .insert_into_history (line )
401+ if insert_into_history :
402+ self .insert_into_history (line )
402403 t = threading .Thread (target = self .runsource , args = (line ,))
403404 t .daemon = True
404405 t .start ()
@@ -682,7 +683,7 @@ def reprint_line(self, lineno, tokens):
682683 logging .debug ("calling reprint line with %r %r" , lineno , tokens )
683684 if self .config .syntax :
684685 self .display_buffer [lineno ] = bpythonparse (format (tokens , self .formatter ))
685- def reevaluate (self ):
686+ def reevaluate (self , insert_into_history = False ):
686687 """bpython.Repl.undo calls this"""
687688 #TODO other implementations have a enter no-history method, could do
688689 # that instead of clearing history and getting it rewritten
@@ -700,7 +701,7 @@ def reevaluate(self):
700701
701702 for line in old_logical_lines :
702703 self ._current_line = line
703- self .on_enter ()
704+ self .on_enter (insert_into_history = insert_into_history )
704705 self .cursor_offset_in_line = 0
705706 self ._current_line = ''
706707 def getstdout (self ):
@@ -719,7 +720,7 @@ def external_editor(self):
719720 subprocess .call ([editor , temp .name ])
720721 self .history = [line for line in open (temp .name ).read ().split ('\n ' )
721722 if line [:4 ] != '### ' ]
722- self .reevaluate ()
723+ self .reevaluate (insert_into_history = True )
723724
724725def simple_repl ():
725726 with Repl () as r :
0 commit comments