Skip to content

Commit 7306686

Browse files
don't paint current line again if user code exits
--HG-- branch : scroll-frontend
1 parent 5c5014a commit 7306686

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

bpython/scroll.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from fmtstr.terminalcontrol import TerminalController
66

77
from bpython.scrollfrontend.repl import Repl
8+
from bpython.scrollfrontend.coderunner import SystemExitFromCodeThread
89
from bpython import args as bpargs
910
from bpython.translations import _
1011

@@ -47,6 +48,10 @@ def main(args=None, locals_=None, banner=None):
4748
while True:
4849
try:
4950
repl.process_event(tc.get_event())
51+
except SystemExitFromCodeThread:
52+
array, cursor_pos = repl.paint(about_to_exit=2)
53+
term.render_to_terminal(array, cursor_pos)
54+
raise
5055
except SystemExit:
5156
array, cursor_pos = repl.paint(about_to_exit=True)
5257
term.render_to_terminal(array, cursor_pos)

bpython/scrollfrontend/repl.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,8 @@ def paint(self, about_to_exit=False):
674674
arr[:history.height,:history.width] = history
675675

676676
current_line = paint.paint_current_line(min_height, width, self.current_cursor_line)
677+
if about_to_exit == 2: # hack for quit() in user code
678+
current_line_start_row = current_line_start_row - current_line.height
677679
logging.debug("---current line row slice %r, %r", current_line_start_row, current_line_start_row + current_line.height)
678680
logging.debug("---current line col slice %r, %r", 0, current_line.width)
679681
arr[current_line_start_row:current_line_start_row + current_line.height,

0 commit comments

Comments
 (0)