Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fd6315e

Browse files
committed
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.
1 parent e066134 commit fd6315e

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Tools/idle/PyShell.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,11 @@ def enter_callback(self, event):
527527
# No stdin mark -- just get the current line
528528
self.recall(self.text.get("insert linestart", "insert lineend"))
529529
return "break"
530+
# If we're in the current input and there's only whitespace
531+
# beyond the cursor, erase that whitespace first
532+
s = self.text.get("insert", "end-1c")
533+
if s and not string.strip(s):
534+
self.text.delete("insert", "end-1c")
530535
# If we're in the current input before its last line,
531536
# insert a newline right at the insert point
532537
if self.text.compare("insert", "<", "end-1c linestart"):

0 commit comments

Comments
 (0)