Issue 38862: IDLE: Include end newlines in whitespace fix. (original) (raw)

Currently, iomenu.IOBinding.fixnewlines makes sure that when a non-empty non-Shell file is saved (and possibly run), it ends with at least 1 newline. At one time, I believe, compile needed this, and it is still good practice. (Git diffs note the absence of a final newline.)

I originally planned to incorporate possible newline addition into do_rstrip, in anticipation of calling do_rstrip on save, but I have changed my mind, at least for the present. That code can stay where it is. If someone explicitly runs Strip Trailing Whitespace, adding a newline would sometimes be desired, but would sometimes be unexpected and possibly a nuisance. do_rstrip will ensure that non-Shell files end with at most 1 newline.

My revised intent is that once we strip on save, saved files should be properly formatted for use or merging into a repository.