]> granicus.if.org Git - python/commitdiff
If we're in the current input and there's only whitespace beyond the
authorGuido van Rossum <guido@python.org>
Tue, 7 Mar 2000 15:05:50 +0000 (15:05 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 7 Mar 2000 15:05:50 +0000 (15:05 +0000)
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.

Tools/idle/PyShell.py

index 1e2f1ae3d2aed0e898bce5f3d5ea6fbfbe2f9332..6a4712ef6a80e1b2ea7bcb1277134d74330620e4 100644 (file)
@@ -527,6 +527,11 @@ class PyShell(OutputWindow):
             # No stdin mark -- just get the current line
             self.recall(self.text.get("insert linestart", "insert lineend"))
             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,
         # insert a newline right at the insert point
         if self.text.compare("insert", "<", "end-1c linestart"):