your-tools / ruplacer

Find and replace text in source files
BSD 3-Clause "New" or "Revised" License
443 stars 25 forks source link

Handle trailing newlines consistently in FilePatcher #67

Closed LawnGnome closed 3 years ago

LawnGnome commented 3 years ago

Previously, FilePatcher could not differentiate between files with and without trailing newlines, and always wrote files with trailing newlines. As a result, files without trailing newlines that were otherwise unchanged would be modified.

This commit introduces a new LineIterator that preserves the trailing delimiter, if present, and ensures that files are written with the same newline structure they had when read.

dmerejkowsky commented 3 years ago

Excellent :) Thanks a lot

dmerejkowsky commented 3 years ago

Also, I should say It's pretty nice to see my little pet project featured in sourcegraph's documentation :)

LawnGnome commented 3 years ago

Also, I should say It's pretty nice to see my little pet project featured in sourcegraph's documentation :)

We're really grateful to you for writing it! Thanks; we like it a lot. :smiley: