X Tutup
Skip to content

Commit 1389af4

Browse files
make self.done a property based on self.buffer
1 parent 4224a3f commit 1389af4

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

bpython/curtsiesfrontend/repl.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ def smarter_request_refresh():
204204
self.scroll_offset = 0 # how many times display has been scrolled down
205205
# because there wasn't room to display everything
206206
self.cursor_offset_in_line = 0 # from the left, 0 means first char
207-
self.done = True # whether the current block is finished yet
208207

209208
self.coderunner = CodeRunner(self.interp, self.request_refresh)
210209
self.stdout = FakeOutput(self.coderunner, self.send_to_stdout)
@@ -220,6 +219,11 @@ def smarter_request_refresh():
220219
self.height = None
221220
self.start_background_tasks()
222221

222+
@property
223+
def done(self):
224+
"""Whether the last block is complete - which prompt to use, ps1 or ps2"""
225+
return not self.buffer
226+
223227
def __enter__(self):
224228
self.orig_stdout = sys.stdout
225229
self.orig_stderr = sys.stderr
@@ -529,7 +533,6 @@ def run_code_and_maybe_finish(self, for_code=None):
529533

530534
self._current_line = ' '*indent
531535
self.cursor_offset_in_line = len(self._current_line)
532-
self.done = not unfinished
533536

534537
def keyboard_interrupt(self):
535538
#TODO factor out the common cleanup from running a line
@@ -545,7 +548,6 @@ def keyboard_interrupt(self):
545548
self.saved_indent = 0
546549
self._current_line = ''
547550
self.cursor_offset_in_line = len(self._current_line)
548-
self.done = True
549551

550552
def unhighlight_paren(self):
551553
"""modify line in self.display_buffer to unhighlight a paren if possible
@@ -835,8 +837,6 @@ def reevaluate(self, insert_into_history=False):
835837
self.history = []
836838
self.display_lines = []
837839

838-
self.done = True # this keeps the first prompt correct
839-
840840
if not self.weak_rewind:
841841
self.interp = code.InteractiveInterpreter()
842842
self.coderunner.interp = self.interp
@@ -888,7 +888,6 @@ def clear_current_block(self):
888888
self.saved_indent = 0
889889
self._current_line = ''
890890
self.cursor_offset_in_line = len(self._current_line)
891-
self.done = True
892891

893892
def send_current_block_to_external_editor(self, filename=None):
894893
text = self.send_to_external_editor(self.get_current_block())

0 commit comments

Comments
 (0)
X Tutup