diff --git a/qtconsole/console_widget.py b/qtconsole/console_widget.py index 20a30873..2b1f7435 100644 --- a/qtconsole/console_widget.py +++ b/qtconsole/console_widget.py @@ -2519,9 +2519,6 @@ def _show_prompt(self, prompt=None, html=False, newline=True, cursor = self._get_end_cursor() - # Memorize end to check if we actually add any prompt characters - prior_end_pos = cursor.position() - # Save the current position to support _append*(before_prompt=True). # We can't leave the cursor at the end of the document though, because # that would cause any further additions to move the cursor. Therefore, @@ -2560,16 +2557,7 @@ def _show_prompt(self, prompt=None, html=False, newline=True, self._prompt_html = None self._flush_pending_stream() - - current_end_pos = self._get_end_pos() - if prior_end_pos != current_end_pos: - # Set the prompt cursor to end minus 1, so long as - # the prompt was not blank - self._prompt_cursor.setPosition(current_end_pos - 1) - else: - # The prompt didn't move end, i.e. the prompt inserted exactly 0 characters - # Move cursor to end - self._prompt_cursor.setPosition(current_end_pos) + self._prompt_cursor.setPosition(self._get_end_pos() - 1) if move_forward: self._append_before_prompt_cursor.setPosition( diff --git a/qtconsole/tests/test_00_console_widget.py b/qtconsole/tests/test_00_console_widget.py index 69368529..fa23b48b 100644 --- a/qtconsole/tests/test_00_console_widget.py +++ b/qtconsole/tests/test_00_console_widget.py @@ -491,15 +491,6 @@ def test_prompt_cursors(self): self.assertEqual(w._append_before_prompt_pos, w._prompt_pos - len(w._prompt)) - # Test a blank prompt. Such as from input() - w._append_plain_text('\n') - w._show_prompt(prompt = '', separator = False) - - w._append_plain_text('plain text\n') - - self.assertEqual(w._prompt_pos, w._get_end_pos()) - self.assertEqual(w._append_before_prompt_pos, w._prompt_pos) - def test_select_all(self): w = ConsoleWidget() w._append_plain_text('Header\n')