diff options
Diffstat (limited to 'Lib/idlelib/format.py')
-rw-r--r-- | Lib/idlelib/format.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/idlelib/format.py b/Lib/idlelib/format.py index 2b09805657..4b57a182c9 100644 --- a/Lib/idlelib/format.py +++ b/Lib/idlelib/format.py @@ -408,6 +408,16 @@ class Rstrip: # 'Strip Trailing Whitespace" on "Format" menu. if cut < raw: text.delete('%i.%i' % (cur, cut), '%i.end' % cur) + if (text.get('end-2c') == '\n' # File ends with at least 1 newline; + and not hasattr(self.editwin, 'interp')): # & is not Shell. + # Delete extra user endlines. + while (text.index('end-1c') > '1.0' # Stop if file empty. + and text.get('end-3c') == '\n'): + text.delete('end-3c') + # Because tk indexes are slice indexes and never raise, + # a file with only newlines will be emptied. + # patchcheck.py does the same. + undo.undo_block_stop() |