If we're in the current input and there's only whitespace beyond the

cursor, erase that whitespace first.  This avoids a particularly
confusing case where hitting Return at the end of the command didn't
do what it was expected to do -- because it wasn't considered to be at
the end of the command.  Now it is.
This commit is contained in:
Guido van Rossum 2000-03-07 15:05:50 +00:00
parent e066134f48
commit fd6315ec7f
1 changed files with 5 additions and 0 deletions

View File

@ -527,6 +527,11 @@ class PyShell(OutputWindow):
# No stdin mark -- just get the current line # No stdin mark -- just get the current line
self.recall(self.text.get("insert linestart", "insert lineend")) self.recall(self.text.get("insert linestart", "insert lineend"))
return "break" return "break"
# If we're in the current input and there's only whitespace
# beyond the cursor, erase that whitespace first
s = self.text.get("insert", "end-1c")
if s and not string.strip(s):
self.text.delete("insert", "end-1c")
# If we're in the current input before its last line, # If we're in the current input before its last line,
# insert a newline right at the insert point # insert a newline right at the insert point
if self.text.compare("insert", "<", "end-1c linestart"): if self.text.compare("insert", "<", "end-1c linestart"):