Don't move cursor back then forward if there is no banner
@@ -2123,8 +2123,13 @@ class ConsoleWidget(MetaQObjectHasTraits('NewBase', (LoggingConfigurable, superQ
# 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,
# we move it back one place and move it forward again at the end of
- # this method.
- self._append_before_prompt_cursor.setPosition(cursor.position() - 1)
+ # this method. However, we only do this if the cursor isn't already
+ # at the start of the text.
+ if cursor.position() == 0:
+ move_forward = False
+ else:
+ move_forward = True
+ self._append_before_prompt_cursor.setPosition(cursor.position())
# Insert a preliminary newline, if necessary.
if newline and cursor.position() > 0:
@@ -2151,6 +2156,8 @@ class ConsoleWidget(MetaQObjectHasTraits('NewBase', (LoggingConfigurable, superQ
self._flush_pending_stream()
self._prompt_cursor.setPosition(self._get_end_pos() - 1)
+
+ if move_forward:
self._append_before_prompt_cursor.setPosition(
self._append_before_prompt_cursor.position() + 1)
self._prompt_started()
