Skip to content

Commit

Permalink
fix Ctrl+G/esc intercepted bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Carreau committed Jun 10, 2012
1 parent 3cb4e60 commit f7faea8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions IPython/frontend/qt/console/console_widget.py
Expand Up @@ -171,7 +171,7 @@ def _font_family_default(self):
[ QtCore.Qt.Key_C, QtCore.Qt.Key_G, QtCore.Qt.Key_O,
QtCore.Qt.Key_V ])

_is_completing = False
_temp_buffer_filled = False

#---------------------------------------------------------------------------
# 'QObject' interface
Expand Down Expand Up @@ -850,6 +850,7 @@ def _clear_temporary_buffer(self):
the prompt region.
"""
# Select and remove all text below the input buffer.
_temp_buffer_filled = False
cursor = self._get_prompt_cursor()
prompt = self._continuation_prompt.lstrip()
while cursor.movePosition(QtGui.QTextCursor.NextBlock):
Expand Down Expand Up @@ -894,7 +895,6 @@ def _complete_with_items(self, cursor, items):

cursor.movePosition(QtGui.QTextCursor.Left, n=len(prefix))
self._completion_widget.show_items(cursor, items)
self._is_completing = True


def _fill_temporary_buffer(self, cursor, text, html=False):
Expand All @@ -911,6 +911,8 @@ def _fill_temporary_buffer(self, cursor, text, html=False):
self._control.moveCursor(QtGui.QTextCursor.End)
self._control.setTextCursor(cursor)

_temp_buffer_filled = True


def _context_menu_make(self, pos):
""" Creates a context menu for the given QPoint (in widget coordinates).
Expand Down Expand Up @@ -1654,8 +1656,9 @@ def _keep_cursor_in_buffer(self):
def _keyboard_quit(self):
""" Cancels the current editing task ala Ctrl-G in Emacs.
"""
if self._is_completing:
if self._temp_buffer_filled :
self._cancel_completion()
self._clear_temporary_buffer()
else:
self.input_buffer = ''

Expand Down

0 comments on commit f7faea8

Please sign in to comment.