Closed
Description
I created two text files, t1.txt:
line1
line2
line3
and t2.txt:
line1
line2
line33
Neither of them have a newline at the end.
Using the diff
tool, I get:
$ ls
t1.txt t2.txt
$ diff -u t1.txt t2.txt
--- t1.txt 2015-12-29 00:46:20.201829172 -0300
+++ t2.txt 2015-12-29 00:46:28.146828695 -0300
@@ -1,3 +1,3 @@
line1
line2
-line3
\ No newline at end of file
+line33
\ No newline at end of file
Using jsdiff
, I get (on Node):
> var p = diff.createPatch("", "line1\nline2\nline3", "line1\nline2\nline33")
undefined
> console.log(p)
Index:
===================================================================
---
+++
@@ -1,3 +1,3 @@
line1
line2
-line3
\ No newline at end of file
+line33
There's a \ No newline at end of file
missing after +line33
.
I think this only happens when the last line has changed, but both new and old versions don't end in a newline. I couldn't find a test case in https://github.com/kpdecker/jsdiff/blob/master/test/patch/create.js which covers this case.
Tested on 2.2.1.
Metadata
Metadata
Assignees
Labels
No labels