Skip to content

Commit

Permalink
Consider blank lines at the end of a file
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-ballario committed Jan 14, 2022
1 parent 3eb8960 commit c977587
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,9 @@ pub fn guess_language<P: AsRef<Path>>(buf: &[u8], path: P) -> (Option<LANG>, Str
pub(crate) fn remove_blank_lines(data: &mut Vec<u8>) {
let count_trailing = data.iter().rev().take_while(|&c| *c == b'\n').count();
if count_trailing > 0 {
data.truncate(data.len() - count_trailing + 1);
} else {
data.push(b'\n');
data.truncate(data.len() - count_trailing);
}
data.push(b'\n');
}

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

0 comments on commit c977587

Please sign in to comment.