diff -r 74144b0e7858 Lib/idlelib/EditorWindow.py --- a/Lib/idlelib/EditorWindow.py Sun Mar 16 13:55:19 2014 +1000 +++ b/Lib/idlelib/EditorWindow.py Tue Mar 18 09:27:45 2014 +0800 @@ -1388,6 +1388,8 @@ # indentation of initial line of closest preceding # interesting stmt. indent = y.get_base_indent_string() + if self.context_use_ps1 and y.is_first_line_continuation(): + indent = ' ' * len(sys.ps1.split('\n')[-1]) + indent text.insert("insert", indent) if y.is_block_opener(): self.smart_indent_event(event) diff -r 74144b0e7858 Lib/idlelib/PyParse.py --- a/Lib/idlelib/PyParse.py Sun Mar 16 13:55:19 2014 +1000 +++ b/Lib/idlelib/PyParse.py Tue Mar 18 09:27:45 2014 +0800 @@ -358,6 +358,7 @@ # Set p and q to slice indices of last interesting stmt. str, goodlines = self.str, self.goodlines + self.isfirstlinecont = str.count('\n') == 1 i = len(goodlines) - 1 p = len(str) # index of newest line while i: @@ -588,3 +589,9 @@ def get_last_stmt_bracketing(self): self._study2() return self.stmt_bracketing + + # Is this a continuation of the first line after a prompt? + def is_first_line_continuation(self): + self._study2() + return self.isfirstlinecont + diff -r 74144b0e7858 Lib/idlelib/PyShell.py --- a/Lib/idlelib/PyShell.py Sun Mar 16 13:55:19 2014 +1000 +++ b/Lib/idlelib/PyShell.py Tue Mar 18 09:27:45 2014 +0800 @@ -866,9 +866,6 @@ OutputWindow.__init__(self, flist, None, None) # ## self.config(usetabs=1, indentwidth=8, context_use_ps1=1) - self.usetabs = True - # indentwidth must be 8 when using tabs. See note in EditorWindow: - self.indentwidth = 8 self.context_use_ps1 = True # text = self.text @@ -1265,6 +1262,8 @@ source = self.text.get("iomark", "end-1c") if self.history: self.history.store(source) + if self.text.get("end-1c linestart", "end").strip() == "": + self.text.delete("end-1c linestart", "end") if self.text.get("end-2c") != "\n": self.text.insert("end-1c", "\n") self.text.mark_set("iomark", "end-1c")