@@ -1021,15 +1021,23 @@ def paint(self, about_to_exit=False, user_quit=False):
10211021 else :
10221022 arr = FSArray (0 , width )
10231023 #TODO test case of current line filling up the whole screen (there aren't enough rows to show it)
1024- if self .inconsistent_history == True :
1025- msg = "#<---History inconsistent with output shown--->"
1026- arr [0 , 0 :min (len (msg ), width )] = [msg [:width ]]
1027- self .inconsistent_history = False
1028- """FIX THE THING This if may need to go after the second one, but the while applies to both"""
1029- if current_line_start_row < 0 : #if current line trying to be drawn off the top of the screen
1030- logger .debug ('#<---History contiguity broken by rewind--->' )
1031- msg = "#<---History contiguity broken by rewind--->"
1032- arr [0 , 0 :min (len (msg ), width )] = [msg [:width ]]
1024+ if self .inconsistent_history == False & current_line_start_row >= 0 :
1025+ history = paint .paint_history (current_line_start_row , width , self .lines_for_display )
1026+ arr [:history .height ,:history .width ] = history
1027+
1028+ else :
1029+ if self .inconsistent_history == True :
1030+ logger .debug ("#<---History inconsistent with output shown--->" )
1031+ msg = "#<---History inconsistent with output shown--->"
1032+ arr [0 , 0 :min (len (msg ), width )] = [msg [:width ]]
1033+ self .inconsistent_history = False
1034+ # self.scroll_offset -= 1
1035+ current_line_start_row = len (self .lines_for_display )- max (- 1 , self .scroll_offset )
1036+
1037+ if current_line_start_row < 0 : #if current line trying to be drawn off the top of the screen
1038+ logger .debug ('#<---History contiguity broken by rewind--->' )
1039+ msg = "#<---History contiguity broken by rewind--->"
1040+ arr [0 , 0 :min (len (msg ), width )] = [msg [:width ]]
10331041
10341042 # move screen back up a screen minus a line
10351043 while current_line_start_row < 0 :
@@ -1041,9 +1049,7 @@ def paint(self, about_to_exit=False, user_quit=False):
10411049
10421050 if arr .height <= min_height :
10431051 arr [min_height , 0 ] = ' ' # force scroll down to hide broken history message
1044- else :
1045- history = paint .paint_history (current_line_start_row , width , self .lines_for_display )
1046- arr [:history .height ,:history .width ] = history
1052+
10471053
10481054 current_line = paint .paint_current_line (min_height , width , self .current_cursor_line )
10491055 if user_quit : # quit() or exit() in interp
@@ -1252,7 +1258,12 @@ def reevaluate(self, insert_into_history=False):
12521258 self .reevaluating = False
12531259 num_lines_onscreen = len (self .lines_for_display )- max (0 , self .scroll_offset )
12541260 if old_display_lines [:len (self .display_lines )- num_lines_onscreen ]!= self .display_lines :
1261+ old_display_lines_offscreen = old_display_lines [:len (self .display_lines )- num_lines_onscreen ]
1262+ display_lines_offscreen = self .display_lines [:- num_lines_onscreen ]
1263+
1264+ if old_display_lines_offscreen != display_lines_offscreen :
12551265 self .inconsistent_history = True
1266+ self .scroll_offset = self .scroll_offset - max (- 1 ,(len (old_display_lines_offscreen )- len (display_lines_offscreen )+ 1 ))
12561267 self .cursor_offset = 0
12571268 self .current_line = ''
12581269
0 commit comments