##// END OF EJS Templates
* Fixed bug with terminal-style tab completion for multi-line input....
epatters -
Show More
@@ -563,11 +563,15 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
563 the prompt region.
563 the prompt region.
564 """
564 """
565 cursor = self._get_prompt_cursor()
565 cursor = self._get_prompt_cursor()
566 found_block = cursor.movePosition(QtGui.QTextCursor.NextBlock)
566 if cursor.movePosition(QtGui.QTextCursor.NextBlock):
567 if found_block:
567 prompt = self._continuation_prompt.lstrip()
568 while found_block and \
568 while True:
569 cursor.block().text().startsWith(self._continuation_prompt):
569 temp_cursor = QtGui.QTextCursor(cursor)
570 found_block = cursor.movePosition(QtGui.QTextCursor.NextBlock)
570 temp_cursor.select(QtGui.QTextCursor.BlockUnderCursor)
571 text = str(temp_cursor.selection().toPlainText()).lstrip()
572 if not text.startswith(prompt) or \
573 not cursor.movePosition(QtGui.QTextCursor.NextBlock):
574 break
571 cursor.movePosition(QtGui.QTextCursor.Left) # Grab the newline.
575 cursor.movePosition(QtGui.QTextCursor.Left) # Grab the newline.
572 cursor.movePosition(QtGui.QTextCursor.End,
576 cursor.movePosition(QtGui.QTextCursor.End,
573 QtGui.QTextCursor.KeepAnchor)
577 QtGui.QTextCursor.KeepAnchor)
@@ -12,6 +12,7 b''
12
12
13 # Standard library imports
13 # Standard library imports
14 from collections import namedtuple
14 from collections import namedtuple
15 import re
15 from subprocess import Popen
16 from subprocess import Popen
16
17
17 # System library imports
18 # System library imports
@@ -127,12 +128,20 b' class IPythonWidget(FrontendWidget):'
127 cursor = self._get_cursor()
128 cursor = self._get_cursor()
128 if rep['parent_header']['msg_id'] == self._complete_id and \
129 if rep['parent_header']['msg_id'] == self._complete_id and \
129 cursor.position() == self._complete_pos:
130 cursor.position() == self._complete_pos:
130 # The completer tells us what text was actually used for the
131 matches = rep['content']['matches']
131 # matching, so we must move that many characters left to apply the
132 # completions.
133 text = rep['content']['matched_text']
132 text = rep['content']['matched_text']
133
134 # Clean up matches with '.'s and path separators.
135 parts = re.split(r'[./\\]', text)
136 sep_count = len(parts) - 1
137 if sep_count:
138 chop_length = sum(map(len, parts[:sep_count])) + sep_count
139 matches = [ match[chop_length:] for match in matches ]
140 text = text[chop_length:]
141
142 # Move the cursor to the start of the match and complete.
134 cursor.movePosition(QtGui.QTextCursor.Left, n=len(text))
143 cursor.movePosition(QtGui.QTextCursor.Left, n=len(text))
135 self._complete_with_items(cursor, rep['content']['matches'])
144 self._complete_with_items(cursor, matches)
136
145
137 def _handle_history_reply(self, msg):
146 def _handle_history_reply(self, msg):
138 """ Implemented to handle history replies, which are only supported by
147 """ Implemented to handle history replies, which are only supported by
General Comments 0
You need to be logged in to leave comments. Login now