From fc996939f8b023ee48953076cf06d8caa784b08c 2010-01-11 03:57:40 From: Fernando Perez Date: 2010-01-11 03:57:40 Subject: [PATCH] Fix bug with autocall and multiline input recalled from readline buffer. Reported by John Hunter on list. --- diff --git a/IPython/core/prefilter.py b/IPython/core/prefilter.py index c8fbb0f..a7a4f10 100755 --- a/IPython/core/prefilter.py +++ b/IPython/core/prefilter.py @@ -427,11 +427,19 @@ class PrefilterManager(Component): which is the case when the user goes back to a multiline history entry and presses enter. """ - out = [] - for line in lines.rstrip('\n').split('\n'): - out.append(self.prefilter_line(line, continue_prompt)) - return '\n'.join(out) - + llines = lines.rstrip('\n').split('\n') + # We can get multiple lines in one shot, where multiline input 'blends' + # into one line, in cases like recalling from the readline history + # buffer. We need to make sure that in such cases, we correctly + # communicate downstream which line is first and which are continuation + # ones. + if len(llines) > 1: + out = '\n'.join([self.prefilter_line(line, lnum>0) + for lnum, line in enumerate(llines) ]) + else: + out = self.prefilter_line(llines[0], continue_prompt) + + return out #----------------------------------------------------------------------------- # Prefilter transformers