##// END OF EJS Templates
tweak history prefix search (up/^p) in qtconsole...
MinRK -
Show More
@@ -76,9 +76,21 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)):
82 self._history_prefix = input_buffer[:col]
94 self._history_prefix = input_buffer[:col]
83
95
84 # Perform the search.
96 # Perform the search.
General Comments 0
You need to be logged in to leave comments. Login now