Show More
@@ -76,9 +76,22 b' class HistoryConsoleWidget(ConsoleWidget):' | |||||
76 | # Set a search prefix based on the cursor position. |
|
76 | # Set a search prefix based on the cursor position. | |
77 | col = self._get_input_buffer_cursor_column() |
|
77 | col = self._get_input_buffer_cursor_column() | |
78 | input_buffer = self.input_buffer |
|
78 | input_buffer = self.input_buffer | |
79 | if self._history_index == len(self._history) or \ |
|
79 | # use the *shortest* of the cursor column and the history prefix | |
80 | (self._history_prefix and col != len(self._history_prefix)): |
|
80 | # to determine if the prefix has changed | |
|
81 | n = min(col, len(self._history_prefix)) | |||
|
82 | ||||
|
83 | # prefix changed, restart search from the beginning | |||
|
84 | if (self._history_prefix[:n] != input_buffer[:n]): | |||
81 | self._history_index = len(self._history) |
|
85 | self._history_index = len(self._history) | |
|
86 | ||||
|
87 | # the only time we shouldn't set the history prefix | |||
|
88 | # to the line up to the cursor is if we are already | |||
|
89 | # in a simple scroll (no prefix), | |||
|
90 | # and the cursor is at the end of the first line | |||
|
91 | first_line = input_buffer.split('\n', 1)[0] | |||
|
92 | if self._history_index == len(self._history) or \ | |||
|
93 | not (self._history_prefix == '' and col == len(first_line)) or \ | |||
|
94 | not (self._get_edited_history(self._history_index)[:col] == input_buffer[:col]): | |||
82 | self._history_prefix = input_buffer[:col] |
|
95 | self._history_prefix = input_buffer[:col] | |
83 |
|
96 | |||
84 | # Perform the search. |
|
97 | # Perform the search. | |
@@ -179,7 +192,7 b' class HistoryConsoleWidget(ConsoleWidget):' | |||||
179 | """ |
|
192 | """ | |
180 | index = self._history_index |
|
193 | index = self._history_index | |
181 | replace = False |
|
194 | replace = False | |
182 |
while |
|
195 | while index < len(self._history): | |
183 | index += 1 |
|
196 | index += 1 | |
184 | history = self._get_edited_history(index) |
|
197 | history = self._get_edited_history(index) | |
185 | if (as_prefix and history.startswith(substring)) \ |
|
198 | if (as_prefix and history.startswith(substring)) \ |
General Comments 0
You need to be logged in to leave comments.
Login now