summaryrefslogtreecommitdiffstats
path: root/Tools/idle/PyShell.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-03-07 15:05:50 (GMT)
committerGuido van Rossum <guido@python.org>2000-03-07 15:05:50 (GMT)
commitfd6315ec7f61b4170d243b0272f6f5362807849a (patch)
treebca9edbeafe70307c163450c2fe39956b9b51f0a /Tools/idle/PyShell.py
parente066134f482f8e3fa427a9f84892b39faff72627 (diff)
downloadcpython-fd6315ec7f61b4170d243b0272f6f5362807849a.zip
cpython-fd6315ec7f61b4170d243b0272f6f5362807849a.tar.gz
cpython-fd6315ec7f61b4170d243b0272f6f5362807849a.tar.bz2
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.
Diffstat (limited to 'Tools/idle/PyShell.py')
-rw-r--r--Tools/idle/PyShell.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Tools/idle/PyShell.py b/Tools/idle/PyShell.py
index 1e2f1ae..6a4712e 100644
--- a/Tools/idle/PyShell.py
+++ b/Tools/idle/PyShell.py
@@ -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"):