Append newline at the end of the file if necessary
commit8b9991d7808d65782844ac68a2f9c53fa4225dc6
authorsharkdp <davidpeter@web.de>
dateTue 8 May 2018, 23:49 (9 years ago)
parentf59ddd1
src/main.rs+6−1
@@ -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