summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsharkdp <davidpeter@web.de>2018-05-08 23:49:59 +0200
committersharkdp <davidpeter@web.de>2018-05-08 23:49:59 +0200
commit8b9991d7808d65782844ac68a2f9c53fa4225dc6 (patch)
treecd1ebc29c35ee3019d6d680a9eae4f2499e4124c
parentf59ddd1e3607664800b58657404215e8e8cb7592 (diff)
Append newline at the end of the file if necessaryv0.3.0
-rw-r--r--src/main.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index 78c794cb..773f3432 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -199,7 +199,12 @@ fn print_file(
Ok(0) => {
break;
}
- Ok(_) => &line_buffer,
+ Ok(_) => {
+ if !line_buffer.ends_with("\n") {
+ line_buffer.push('\n');
+ }
+ &line_buffer
+ }
Err(_) => "<bat: INVALID UTF-8>\n",
};