Skip to content

Commit

Permalink
Remove unnecessary blank line when last line had no EOL marker and co…
Browse files Browse the repository at this point in the history
…ntained only trailing spaces.
  • Loading branch information
tamere-allo-peter committed Jul 6, 2022
1 parent f663af5 commit 374ecae
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion yamlfixer/problemfixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ def fix_newlineateof(self, left, right): # pylint: disable=unused-argument,no-s
- no new line character at the end of file
- wrong new line character: expected \n
""" # noqa: D205, D208, D400
# We simply ignore it, because we always add \n when dumping
if not (left or right):
# We came here because last line contained only trailing spaces
del self.ffixer.lines[self.linenum]
self.ffixer.loffset -= 1

# Else we simply ignore it, because we always add \n when dumping
# and rely on universal newlines to handle them correctly.
# FIXME : doesn't work when transcoding files for another OS.

Expand Down

0 comments on commit 374ecae

Please sign in to comment.