Skip to content

Commit

Permalink
Merge 6ad2c67 into 06cd544
Browse files Browse the repository at this point in the history
  • Loading branch information
impact27 committed Mar 22, 2019
2 parents 06cd544 + 6ad2c67 commit 05a1b14
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
4 changes: 3 additions & 1 deletion qtconsole/console_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -2088,7 +2088,9 @@ def _insert_plain_text(self, cursor, text, flush=False):
cursor.endEditBlock()

if self._executing and end_doc_pos - end_scroll_pos <= 1:
self._control.moveCursor(QtGui.QTextCursor.End)
end_scroll = (self._control.verticalScrollBar().maximum()
- self._control.verticalScrollBar().pageStep())
self._control.verticalScrollBar().setValue(end_scroll)

def _insert_plain_text_into_buffer(self, cursor, text):
""" Inserts text into the input buffer using the specified cursor (which
Expand Down
33 changes: 33 additions & 0 deletions qtconsole/tests/test_console_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,3 +414,36 @@ def is_complete(self, source):
w._set_input_buffer(code)
w.execute(interactive=True)
assert responses == [('complete', None)]

def test_debug(self):
"""
Make sure the cursor works while debugging
It might not because the console is "_executing"
"""
# Kernel client to test the responses of is_complete
class TestIPyKernelClient(object):
def is_complete(self, source):
tm = TransformerManager()
check_complete = tm.check_complete(source)
responses.append(check_complete)

# Initialize widget
responses = []
w = ConsoleWidget()
w._append_plain_text('Header\n')
w._prompt = 'prompt>'
w._show_prompt()
w.kernel_client = TestIPyKernelClient()
control = w._control

# Execute incomplete statement inside a block
code = "%debug range(1)\n"
w._set_input_buffer(code)
w.execute(interactive=True)

# We should be able to move the cursor while debugging
w._set_input_buffer("abd")
QTest.keyClick(control, QtCore.Qt.Key_Left)
QTest.keyClick(control, 'c')
self.assertEqual(w._get_input_buffer(),"abcd")

0 comments on commit 05a1b14

Please sign in to comment.