Skip to content

Commit

Permalink
Revert "Fix handling of a blank prompt"
Browse files Browse the repository at this point in the history
Changes actually broke all input() handling. Reverting.

This reverts commit 50bb0fd.
  • Loading branch information
TheMatt2 committed Jun 9, 2024
1 parent 50bb0fd commit ae9e57b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 22 deletions.
14 changes: 1 addition & 13 deletions qtconsole/console_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
9 changes: 0 additions & 9 deletions qtconsole/tests/test_00_console_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit ae9e57b

Please sign in to comment.