From b40a2dd0e08895c827eb936da6c8e8f5997cd51d 2016-01-27 16:38:31 From: Thomas Kluyver Date: 2016-01-27 16:38:31 Subject: [PATCH] Make behaviour more natural with blank lines at the end of input --- diff --git a/IPython/terminal/ptshell.py b/IPython/terminal/ptshell.py index 9f81418..58b2ad6 100644 --- a/IPython/terminal/ptshell.py +++ b/IPython/terminal/ptshell.py @@ -89,11 +89,13 @@ class PTInteractiveShell(InteractiveShell): )) def _(event): b = event.current_buffer - if not b.document.on_last_line: + d = b.document + if not (d.on_last_line or d.cursor_position_row >= d.line_count + - d.empty_line_count_at_the_end()): b.newline() return - status, indent = self.input_splitter.check_complete(b.document.text) + status, indent = self.input_splitter.check_complete(d.text) if (status != 'incomplete') and b.accept_action.is_returnable: b.accept_action.validate_and_handle(event.cli, b)