Skip to content

Commit

Permalink
Minor fix for stripping newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
sirosen committed Oct 17, 2023
1 parent dec6f85 commit 19f75b8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ following sample config:
### Unreleased

<!-- bumpversion-changelog -->
- Bugfix for `alphabetize-codeowners` stripping ending newlines

### 0.6.0

Expand Down
3 changes: 3 additions & 0 deletions src/texthooks/_recorders.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ def run_line_fixer(self, line_fixer: t.Callable[[str], str], filename: str):
newcontent = []
for lineno, line in enumerate(content, 1):
newline = line_fixer(line)
# re-add newline if it was stripped by the fixer
if line.endswith("\n") and not newline.endswith("\n"):
newline += "\n"
newcontent.append(newline)
if newline != line:
self.add(filename, line, newline, lineno)
Expand Down

0 comments on commit 19f75b8

Please sign in to comment.