Skip to content

Commit 24b6daf

Browse files
fix multiple-screen rewind bug (thanks Denis Garcia for reporting)
--HG-- branch : scroll-frontend
1 parent d5da6ea commit 24b6daf

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

bpython/scrollfrontend/repl.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -618,15 +618,16 @@ def paint(self, about_to_exit=False):
618618

619619
if current_line_start_row < 0: #if current line trying to be drawn off the top of the screen
620620
#assert True, 'no room for current line: contiguity of history broken!'
621+
logging.debug('#<---History contiguity broken by rewind--->')
621622
msg = "#<---History contiguity broken by rewind--->"
622623
arr[0, 0:min(len(msg), width)] = [msg[:width]]
623624

624625
# move screen back up a screen minus a line
625-
self.scroll_offset = self.scroll_offset - self.height
626+
while current_line_start_row < 0:
627+
self.scroll_offset = self.scroll_offset - self.height
628+
current_line_start_row = len(self.lines_for_display) - max(-1, self.scroll_offset)
626629

627-
current_line_start_row = len(self.lines_for_display) - max(-1, self.scroll_offset)
628-
629-
history = paint.paint_history(current_line_start_row - 1, width, self.lines_for_display)
630+
history = paint.paint_history(max(0, current_line_start_row - 1), width, self.lines_for_display)
630631
arr[1:history.height+1,:history.width] = history
631632

632633
if arr.height <= min_height:
@@ -636,6 +637,8 @@ def paint(self, about_to_exit=False):
636637
arr[:history.height,:history.width] = history
637638

638639
current_line = paint.paint_current_line(min_height, width, self.current_cursor_line)
640+
logging.debug("---current line row slice %r, %r", current_line_start_row, current_line_start_row + current_line.height)
641+
logging.debug("---current line col slice %r, %r", 0, current_line.width)
639642
arr[current_line_start_row:current_line_start_row + current_line.height,
640643
0:current_line.width] = current_line
641644

0 commit comments

Comments
 (0)