Skip to content

Commit c977587

Browse files
Consider blank lines at the end of a file
1 parent 3eb8960 commit c977587

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/tools.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,9 @@ pub fn guess_language<P: AsRef<Path>>(buf: &[u8], path: P) -> (Option<LANG>, Str
232232
pub(crate) fn remove_blank_lines(data: &mut Vec<u8>) {
233233
let count_trailing = data.iter().rev().take_while(|&c| *c == b'\n').count();
234234
if count_trailing > 0 {
235-
data.truncate(data.len() - count_trailing + 1);
236-
} else {
237-
data.push(b'\n');
235+
data.truncate(data.len() - count_trailing);
238236
}
237+
data.push(b'\n');
239238
}
240239

241240
pub(crate) fn normalize_path<P: AsRef<Path>>(path: P) -> PathBuf {

0 commit comments

Comments
 (0)