Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions python/tkterminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,8 @@ def interact_handle_input(self, cell, script=False):
self._input_buffer = self.clean_code(cell)
transformed_cell = self.IP.transform_cell(self._input_buffer)
status, indent = self.IP.check_complete(transformed_cell)
self._current_indent = indent or ''
if indent:
self._current_indent = indent
if status == 'incomplete':
self.IP.more = True
return
Expand All @@ -805,7 +806,15 @@ def interact_handle_input(self, cell, script=False):
insert_line = int(self.text.index(Tk_.INSERT).split('.')[0])
prompt_line = int(self.text.index('output_end').split('.')[0])
tail = self.text.get('%d.%d' % (insert_line, self._prompt_size), Tk_.END)
if not tail.strip():
if tail.strip():
run_cell = False
else:
lines = cell.split('\n')
if len(lines) <= 2:
run_cell = True
else:
run_cell = not lines[-2][self._prompt_size:].strip()
if run_cell:
self.text.tag_delete('history')
self._input_buffer = self._input_buffer.rstrip() + '\n'
self.text.delete(Tk_.INSERT, Tk_.END)
Expand Down
Loading