summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2020-12-15 14:28:36 +0000
committerDan Davison <dandavison7@gmail.com>2020-12-15 14:28:49 +0000
commit12b357513c11dcdaf968c9c036449147abd3e6be (patch)
tree21f4b03494be92c1fea00683413c85bc6ed779d2
parent05933a7ddb3a6c3bdaec06dfcaf2b75b94f5ef97 (diff)
Ref #428
-rw-r--r--aaa1
-rw-r--r--etc/examples/428-no-newline-at-end-of-file15
-rw-r--r--src/delta.rs3
3 files changed, 19 insertions, 0 deletions
diff --git a/aaa b/aaa
new file mode 100644
index 00000000..7c4a013e
--- /dev/null
+++ b/aaa
@@ -0,0 +1 @@
+aaa \ No newline at end of file
diff --git a/etc/examples/428-no-newline-at-end-of-file b/etc/examples/428-no-newline-at-end-of-file
new file mode 100644
index 00000000..3cacca43
--- /dev/null
+++ b/etc/examples/428-no-newline-at-end-of-file
@@ -0,0 +1,15 @@
+--- minus.txt 2020-12-04 20:47:52.000000000 -0500
++++ plus.txt 2020-12-04 20:48:00.000000000 -0500
+@@ -1,5 +1,5 @@
+-key_0: value_0
+-key_1: value_1
+-key_2: value_2
+-key_3: value_3
+-key_4: value_4
+\ No newline at end of file
++key_0: value_1
++key_1: value_2
++key_2: value_3
++key_3: value_4
++key_4: value_5
+\ No newline at end of file
diff --git a/src/delta.rs b/src/delta.rs
index adcb40ae..fa235919 100644
--- a/src/delta.rs
+++ b/src/delta.rs
@@ -194,6 +194,9 @@ where
} else if state.is_in_hunk() {
// A true hunk line should start with one of: '+', '-', ' '. However, handle_hunk_line
// handles all lines until the state machine transitions away from the hunk states.
+ if line == r"\ No newline at end of file" {
+ continue;
+ }
state = handle_hunk_line(&mut painter, &line, &raw_line, state, config);
painter.emit()?;
continue;