##// END OF EJS Templates
move hlen_before_cell into _replace_rlhist_multiline...
Julian Taylor -
Show More
@@ -229,15 +229,16 class TerminalInteractiveShell(InteractiveShell):
229 229 # handling seems rather unpredictable...
230 230 self.write("\nKeyboardInterrupt in interact()\n")
231 231
232 def _replace_rlhist_multiline(self, source_raw, hlen_before_cell):
232 def _replace_rlhist_multiline(self, source_raw):
233 233 """Store multiple lines as a single entry in history"""
234 234 if self.multiline_history and self.has_readline:
235 235 hlen = self.readline.get_current_history_length()
236 for i in range(hlen - hlen_before_cell):
236 for i in range(hlen - self.hlen_before_cell):
237 237 self.readline.remove_history_item(hlen - i - 1)
238 238 stdin_encoding = sys.stdin.encoding or "utf-8"
239 239 self.readline.add_history(py3compat.unicode_to_str(source_raw.rstrip(),
240 240 stdin_encoding))
241 self.hlen_before_cell = self.readline.get_current_history_length()
241 242
242 243 def interact(self, display_banner=None):
243 244 """Closely emulate the interactive Python console."""
@@ -255,13 +256,13 class TerminalInteractiveShell(InteractiveShell):
255 256 self.show_banner()
256 257
257 258 more = False
258 hlen_before_cell = self.readline.get_current_history_length()
259 259
260 260 # Mark activity in the builtins
261 261 __builtin__.__dict__['__IPYTHON__active'] += 1
262 262
263 263 if self.has_readline:
264 264 self.readline_startup_hook(self.pre_readline)
265 self.hlen_before_cell = self.readline.get_current_history_length()
265 266 # exit_now is set by a call to %Exit or %Quit, through the
266 267 # ask_exit callback.
267 268
@@ -293,8 +294,7 class TerminalInteractiveShell(InteractiveShell):
293 294 try:
294 295 self.write('\nKeyboardInterrupt\n')
295 296 source_raw = self.input_splitter.source_raw_reset()[1]
296 self._replace_rlhist_multiline(source_raw, hlen_before_cell)
297 hlen_before_cell = self.readline.get_current_history_length()
297 self._replace_rlhist_multiline(source_raw)
298 298 more = False
299 299 except KeyboardInterrupt:
300 300 pass
@@ -322,8 +322,7 class TerminalInteractiveShell(InteractiveShell):
322 322 self.edit_syntax_error()
323 323 if not more:
324 324 source_raw = self.input_splitter.source_raw_reset()[1]
325 self._replace_rlhist_multiline(source_raw, hlen_before_cell)
326 hlen_before_cell = self.readline.get_current_history_length()
325 self._replace_rlhist_multiline(source_raw)
327 326 self.run_cell(source_raw, store_history=True)
328 327
329 328 # We are off again...
General Comments 0
You need to be logged in to leave comments. Login now