Show More
@@ -144,23 +144,29 b' class ReadlineNoRecord(object):' | |||||
144 |
|
144 | |||
145 | def __enter__(self): |
|
145 | def __enter__(self): | |
146 | if self._nested_level == 0: |
|
146 | if self._nested_level == 0: | |
147 | self.orig_length = self.current_length() |
|
147 | try: | |
148 |
self. |
|
148 | self.orig_length = self.current_length() | |
|
149 | self.readline_tail = self.get_readline_tail() | |||
|
150 | except (AttributeError, IndexError): # Can fail with pyreadline | |||
|
151 | self.orig_length, self.readline_tail = 999999, [] | |||
149 | self._nested_level += 1 |
|
152 | self._nested_level += 1 | |
150 |
|
153 | |||
151 | def __exit__(self, type, value, traceback): |
|
154 | def __exit__(self, type, value, traceback): | |
152 | self._nested_level -= 1 |
|
155 | self._nested_level -= 1 | |
153 | if self._nested_level == 0: |
|
156 | if self._nested_level == 0: | |
154 | # Try clipping the end if it's got longer |
|
157 | # Try clipping the end if it's got longer | |
155 | e = self.current_length() - self.orig_length |
|
158 | try: | |
156 | if e > 0: |
|
159 | e = self.current_length() - self.orig_length | |
157 |
f |
|
160 | if e > 0: | |
158 | self.shell.readline.remove_history_item(self.orig_length) |
|
161 | for _ in range(e): | |
159 |
|
162 | self.shell.readline.remove_history_item(self.orig_length) | ||
160 | # If it still doesn't match, just reload readline history. |
|
163 | ||
161 | if self.current_length() != self.orig_length \ |
|
164 | # If it still doesn't match, just reload readline history. | |
162 |
|
|
165 | if self.current_length() != self.orig_length \ | |
163 | self.shell.refill_readline_hist() |
|
166 | or self.get_readline_tail() != self.readline_tail: | |
|
167 | self.shell.refill_readline_hist() | |||
|
168 | except (AttributeError, IndexError): | |||
|
169 | pass | |||
164 | # Returning False will cause exceptions to propagate |
|
170 | # Returning False will cause exceptions to propagate | |
165 | return False |
|
171 | return False | |
166 |
|
172 |
General Comments 0
You need to be logged in to leave comments.
Login now