Skip to content

Commit

Permalink
Update qtconsole/console_widget.py
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Althviz Moré <[email protected]>
  • Loading branch information
jsbautista and dalthviz authored Sep 9, 2024
1 parent 7591edd commit 41ea37e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions qtconsole/console_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -2220,13 +2220,19 @@ def _insert_plain_text(self, cursor, text, flush=False):
QtGui.QTextCursor.MoveAnchor)

elif act.action == 'newline':
self.log.debug(self._prompt)
if cursor.block() != cursor.document().lastBlock():
if (
cursor.block() != cursor.document().lastBlock()
and not cursor.document()
.toPlainText()
.endswith(self._prompt)
):
cursor.movePosition(QtGui.QTextCursor.NextBlock)
else:
cursor.movePosition(QtGui.QTextCursor.EndOfLine,
QtGui.QTextCursor.MoveAnchor)
cursor.insertText('\n')
cursor.movePosition(
QtGui.QTextCursor.EndOfLine,
QtGui.QTextCursor.MoveAnchor,
)
cursor.insertText("\n")

# simulate replacement mode
if substring is not None:
Expand Down

0 comments on commit 41ea37e

Please sign in to comment.