Skip to content

Commit 8b9991d

Browse files
committed
Append newline at the end of the file if necessary
1 parent f59ddd1 commit 8b9991d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,12 @@ fn print_file(
199199
Ok(0) => {
200200
break;
201201
}
202-
Ok(_) => &line_buffer,
202+
Ok(_) => {
203+
if !line_buffer.ends_with("\n") {
204+
line_buffer.push('\n');
205+
}
206+
&line_buffer
207+
}
203208
Err(_) => "<bat: INVALID UTF-8>\n",
204209
};
205210

0 commit comments

Comments
 (0)