Show More
@@ -229,13 +229,12 b' class TerminalInteractiveShell(InteractiveShell):' | |||||
229 | # handling seems rather unpredictable... |
|
229 | # handling seems rather unpredictable... | |
230 | self.write("\nKeyboardInterrupt in interact()\n") |
|
230 | self.write("\nKeyboardInterrupt in interact()\n") | |
231 |
|
231 | |||
232 | def _store_multiline_history(self, source_raw): |
|
232 | def _store_multiline_history(self, source_raw, orig_hlen): | |
233 | """Store multiple lines as a single entry in history""" |
|
233 | """Store multiple lines as a single entry in history""" | |
234 | if self.multiline_history and self.has_readline: |
|
234 | if self.multiline_history and self.has_readline: | |
235 | hlen = self.readline.get_current_history_length() |
|
235 | hlen = self.readline.get_current_history_length() | |
236 | lines = len(source_raw.splitlines()) |
|
236 | for i in range(hlen - orig_hlen): | |
237 | for i in range(1, min(hlen, lines) + 1): |
|
237 | self.readline.remove_history_item(hlen - i - 1) | |
238 | self.readline.remove_history_item(hlen - i) |
|
|||
239 | self.readline.add_history(source_raw.rstrip()) |
|
238 | self.readline.add_history(source_raw.rstrip()) | |
240 |
|
239 | |||
241 | def interact(self, display_banner=None): |
|
240 | def interact(self, display_banner=None): | |
@@ -254,6 +253,7 b' class TerminalInteractiveShell(InteractiveShell):' | |||||
254 | self.show_banner() |
|
253 | self.show_banner() | |
255 |
|
254 | |||
256 | more = False |
|
255 | more = False | |
|
256 | hlen = self.readline.get_current_history_length() | |||
257 |
|
257 | |||
258 | # Mark activity in the builtins |
|
258 | # Mark activity in the builtins | |
259 | __builtin__.__dict__['__IPYTHON__active'] += 1 |
|
259 | __builtin__.__dict__['__IPYTHON__active'] += 1 | |
@@ -290,7 +290,9 b' class TerminalInteractiveShell(InteractiveShell):' | |||||
290 | #double-guard against keyboardinterrupts during kbdint handling |
|
290 | #double-guard against keyboardinterrupts during kbdint handling | |
291 | try: |
|
291 | try: | |
292 | self.write('\nKeyboardInterrupt\n') |
|
292 | self.write('\nKeyboardInterrupt\n') | |
293 |
s |
|
293 | source_raw = self.input_splitter.source_raw_reset()[1] | |
|
294 | self._store_multiline_history(source_raw, hlen) | |||
|
295 | hlen = self.readline.get_current_history_length() | |||
294 | more = False |
|
296 | more = False | |
295 | except KeyboardInterrupt: |
|
297 | except KeyboardInterrupt: | |
296 | pass |
|
298 | pass | |
@@ -318,7 +320,8 b' class TerminalInteractiveShell(InteractiveShell):' | |||||
318 | self.edit_syntax_error() |
|
320 | self.edit_syntax_error() | |
319 | if not more: |
|
321 | if not more: | |
320 | source_raw = self.input_splitter.source_raw_reset()[1] |
|
322 | source_raw = self.input_splitter.source_raw_reset()[1] | |
321 | self._store_multiline_history(source_raw) |
|
323 | self._store_multiline_history(source_raw, hlen) | |
|
324 | hlen = self.readline.get_current_history_length() | |||
322 | self.run_cell(source_raw, store_history=True) |
|
325 | self.run_cell(source_raw, store_history=True) | |
323 |
|
326 | |||
324 | # We are off again... |
|
327 | # We are off again... |
General Comments 0
You need to be logged in to leave comments.
Login now