@@ -788,9 +788,11 @@ def readline_kill(self, e):
788
788
else :
789
789
self .cut_buffer = cut
790
790
791
- def on_enter (self , insert_into_history = True ):
791
+ def on_enter (self , insert_into_history = True , reset_rl_history = True ):
792
792
# so the cursor isn't touching a paren TODO: necessary?
793
793
self ._set_cursor_offset (- 1 , update_completion = False )
794
+ if reset_rl_history :
795
+ self .rl_history .reset ()
794
796
795
797
self .history .append (self .current_line )
796
798
self .push (self .current_line , insert_into_history = insert_into_history )
@@ -856,14 +858,7 @@ def yank_from_buffer(self):
856
858
def operate_and_get_next (self ):
857
859
# If we have not navigated back in history
858
860
# ctrl+o will have the same effect as enter
859
- if self .rl_history .index == 0 or self .rl_history .index == 1 :
860
- self .on_enter ()
861
- return
862
-
863
- index = self .rl_history .index
864
- self .on_enter ()
865
- self .rl_history .index = index
866
- self ._set_current_line (self .rl_history .entries [- index ], reset_rl_history = False )
861
+ self .on_enter (reset_rl_history = False )
867
862
868
863
def up_one_line (self ):
869
864
self .rl_history .enter (self .current_line )
@@ -1091,7 +1086,11 @@ def run_code_and_maybe_finish(self, for_code=None):
1091
1086
self .current_stdouterr_line , self .width ))
1092
1087
self .current_stdouterr_line = ''
1093
1088
1094
- self ._set_current_line (' ' * indent , update_completion = True )
1089
+ if self .rl_history .index == 0 :
1090
+ self ._set_current_line (' ' * indent , update_completion = True )
1091
+ else :
1092
+ self ._set_current_line (self .rl_history .entries [- self .rl_history .index ],
1093
+ reset_rl_history = False )
1095
1094
self .cursor_offset = len (self .current_line )
1096
1095
1097
1096
def keyboard_interrupt (self ):
0 commit comments