Skip to content

Commit f721c1d

Browse files
susinmotionthomasballinger
authored andcommitted
fixing bug 393
1 parent df80ea1 commit f721c1d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

bpython/curtsiesfrontend/repl.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ def smarter_request_reload(desc):
308308
self.stdin = FakeStdin(self.coderunner, self, self.edit_keys)
309309

310310
self.request_paint_to_clear_screen = False # next paint should clear screen
311+
self.inconsistent_history = False # offscreen command yields different result from history
311312
self.last_events = [None] * 50 # some commands act differently based on the prev event
312313
# this list doesn't include instances of event.Event,
313314
# only keypress-type events (no refresh screen events etc.)
@@ -1020,7 +1021,11 @@ def paint(self, about_to_exit=False, user_quit=False):
10201021
else:
10211022
arr = FSArray(0, width)
10221023
#TODO test case of current line filling up the whole screen (there aren't enough rows to show it)
1023-
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"""
10241029
if current_line_start_row < 0: #if current line trying to be drawn off the top of the screen
10251030
logger.debug('#<---History contiguity broken by rewind--->')
10261031
msg = "#<---History contiguity broken by rewind--->"
@@ -1216,10 +1221,13 @@ def reprint_line(self, lineno, tokens):
12161221
logger.debug("calling reprint line with %r %r", lineno, tokens)
12171222
if self.config.syntax:
12181223
self.display_buffer[lineno] = bpythonparse(format(tokens, self.formatter))
1224+
1225+
return self.display_lines
12191226
def reevaluate(self, insert_into_history=False):
12201227
"""bpython.Repl.undo calls this"""
12211228
if self.watcher: self.watcher.reset()
12221229
old_logical_lines = self.history
1230+
old_display_lines = self.display_lines
12231231
self.history = []
12241232
self.display_lines = []
12251233

@@ -1242,7 +1250,9 @@ def reevaluate(self, insert_into_history=False):
12421250
self.process_event(events.RefreshRequestEvent())
12431251
sys.stdin = self.stdin
12441252
self.reevaluating = False
1245-
1253+
num_lines_onscreen=len(self.lines_for_display)-max(0, self.scroll_offset)
1254+
if old_display_lines[:len(self.display_lines)-num_lines_onscreen]!=self.display_lines:
1255+
self.inconsistent_history = True
12461256
self.cursor_offset = 0
12471257
self.current_line = ''
12481258

0 commit comments

Comments
 (0)