From 7da2783b15a56a229ebe76d0edf874ca5c95494f 2016-01-18 15:37:51 From: Thomas Kluyver Date: 2016-01-18 15:37:51 Subject: [PATCH] Implement pre-filling prompt from set_next_input() --- diff --git a/IPython/terminal/ptshell.py b/IPython/terminal/ptshell.py index 4e04bcd..40df8bd 100644 --- a/IPython/terminal/ptshell.py +++ b/IPython/terminal/ptshell.py @@ -152,11 +152,19 @@ class PTInteractiveShell(InteractiveShell): def ask_exit(self): self.keep_running = False + rl_next_input = None + + def pre_prompt(self): + if self.rl_next_input: + self.pt_cli.application.buffer.text = self.rl_next_input + self.rl_next_input = None + def interact(self): while self.keep_running: print(self.separate_in, end='') + try: - document = self.pt_cli.run() + document = self.pt_cli.run(pre_run=self.pre_prompt) except EOFError: if self.ask_yes_no('Do you really want to exit ([y]/n)?','y','n'): self.ask_exit()