diff --git a/IPython/frontend/qt/console/completion_lexer.py b/IPython/frontend/qt/console/completion_lexer.py index 55a9d19..abadf0c 100644 --- a/IPython/frontend/qt/console/completion_lexer.py +++ b/IPython/frontend/qt/console/completion_lexer.py @@ -31,7 +31,7 @@ class CompletionLexer(object): not string.endswith('\n'): reversed_tokens.pop(0) - current_op = unicode() + current_op = '' for token, text in reversed_tokens: if is_token_subtype(token, Token.Name): @@ -39,14 +39,14 @@ class CompletionLexer(object): # Handle a trailing separator, e.g 'foo.bar.' if current_op in self._name_separators: if not context: - context.insert(0, unicode()) + context.insert(0, '') # Handle non-separator operators and punction. elif current_op: break context.insert(0, text) - current_op = unicode() + current_op = '' # Pygments doesn't understand that, e.g., '->' is a single operator # in C++. This is why we have to build up an operator from diff --git a/IPython/frontend/qt/console/completion_widget.py b/IPython/frontend/qt/console/completion_widget.py index 5984daf..e2ef3c0 100644 --- a/IPython/frontend/qt/console/completion_widget.py +++ b/IPython/frontend/qt/console/completion_widget.py @@ -112,7 +112,7 @@ class CompletionWidget(QtGui.QListWidget): def _update_current(self): """ Updates the current item based on the current text. """ - prefix = self._current_text_cursor().selectedText() + prefix = self._current_text_cursor().selection().toPlainText() if prefix: items = self.findItems(prefix, (QtCore.Qt.MatchStartsWith | QtCore.Qt.MatchCaseSensitive)) diff --git a/IPython/frontend/qt/console/frontend_widget.py b/IPython/frontend/qt/console/frontend_widget.py index 9736e2e..c33dc58 100644 --- a/IPython/frontend/qt/console/frontend_widget.py +++ b/IPython/frontend/qt/console/frontend_widget.py @@ -274,7 +274,7 @@ class FrontendWidget(HistoryConsoleWidget): cursor = self.textCursor() cursor.movePosition(QtGui.QTextCursor.StartOfLine, QtGui.QTextCursor.KeepAnchor) - text = unicode(cursor.selectedText()) + text = str(cursor.selection().toPlainText()) return self._completion_lexer.get_context(text) def _interrupt_kernel(self):