diff options
-rw-r--r-- | src/diff.c | 16 | ||||
-rw-r--r-- | src/testdir/dumps/Test_diff_bin_01.dump | 20 | ||||
-rw-r--r-- | src/testdir/dumps/Test_diff_bin_02.dump | 20 | ||||
-rw-r--r-- | src/testdir/dumps/Test_diff_bin_03.dump | 20 | ||||
-rw-r--r-- | src/testdir/dumps/Test_diff_bin_04.dump | 20 | ||||
-rw-r--r-- | src/testdir/test_diffmode.vim | 37 | ||||
-rw-r--r-- | src/version.c | 2 |
7 files changed, 131 insertions, 4 deletions
diff --git a/src/diff.c b/src/diff.c index ceb73a6bd..9fb8726b4 100644 --- a/src/diff.c +++ b/src/diff.c @@ -777,9 +777,14 @@ diff_write_buffer(buf_T *buf, diffin_T *din) int orig_len; char_u cbuf[MB_MAXBYTES + 1]; - // xdiff doesn't support ignoring case, fold-case the text. - c = PTR2CHAR(s); - c = MB_CASEFOLD(c); + if (*s == NL) + c = NUL; + else + { + // xdiff doesn't support ignoring case, fold-case the text. + c = PTR2CHAR(s); + c = MB_CASEFOLD(c); + } orig_len = mb_ptr2len(s); if (mb_char2bytes(c, cbuf) != orig_len) // TODO: handle byte length difference @@ -791,7 +796,10 @@ diff_write_buffer(buf_T *buf, diffin_T *din) len += orig_len; } else - ptr[len++] = *s++; + { + ptr[len++] = *s == NL ? NUL : *s; + s++; + } } ptr[len++] = NL; } diff --git a/src/testdir/dumps/Test_diff_bin_01.dump b/src/testdir/dumps/Test_diff_bin_01.dump new file mode 100644 index 000000000..a7d4cce51 --- /dev/null +++ b/src/testdir/dumps/Test_diff_bin_01.dump @@ -0,0 +1,20 @@ +| +0#0000e05#a8a8a8255@1>A+2#0000000#ff404010| +0&#ffd7ff255@33||+1&#ffffff0| +0#0000e05#a8a8a8255@1|a+2#0000000#ff404010| +0&#ffd7ff255@33 +| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0| @33||+1&&| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0| @33 +| +0#0000e05#a8a8a8255@1|c+0#0000000#ffd7ff255| @33||+1&#ffffff0| +0#0000e05#a8a8a8255@1|c+0#0000000#ffd7ff255|^+2#0000e05#ff404010|@| +0#0000000#ffd7ff255@31 +| +0#0000e05#a8a8a8255@1|d+0#0000000#ffffff0| @33||+1&&| +0#0000e05#a8a8a8255@1|d+0#0000000#ffffff0| @33 +| +0#0000e05#a8a8a8255@1|E+2#0000000#ff404010| +0&#ffd7ff255@33||+1&#ffffff0| +0#0000e05#a8a8a8255@1|e+2#0000000#ff404010| +0&#ffd7ff255@33 +| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0| @33||+1&&| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0| @33 +| +0#0000e05#a8a8a8255@1|g+0#0000000#ffffff0| @33||+1&&| +0#0000e05#a8a8a8255@1|g+0#0000000#ffffff0| @33 +|~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|[+3#0000000&|N|o| |N|a|m|e|]| |[|+|]| @5|1|,|1| @11|A|l@1| |[+1&&|N|o| |N|a|m|e|]| |[|+|]| @5|1|,|1| @11|A|l@1 +| +0&&@74 diff --git a/src/testdir/dumps/Test_diff_bin_02.dump b/src/testdir/dumps/Test_diff_bin_02.dump new file mode 100644 index 000000000..64ee1aca2 --- /dev/null +++ b/src/testdir/dumps/Test_diff_bin_02.dump @@ -0,0 +1,20 @@ +| +0#0000e05#a8a8a8255@1>A+0#0000000#ffffff0| @33||+1&&| +0#0000e05#a8a8a8255@1|a+0#0000000#ffffff0| @33 +| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0| @33||+1&&| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0| @33 +| +0#0000e05#a8a8a8255@1|c+0#0000000#ffd7ff255| @33||+1&#ffffff0| +0#0000e05#a8a8a8255@1|c+0#0000000#ffd7ff255|^+2#0000e05#ff404010|@| +0#0000000#ffd7ff255@31 +| +0#0000e05#a8a8a8255@1|d+0#0000000#ffffff0| @33||+1&&| +0#0000e05#a8a8a8255@1|d+0#0000000#ffffff0| @33 +| +0#0000e05#a8a8a8255@1|E+0#0000000#ffffff0| @33||+1&&| +0#0000e05#a8a8a8255@1|e+0#0000000#ffffff0| @33 +| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0| @33||+1&&| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0| @33 +| +0#0000e05#a8a8a8255@1|g+0#0000000#ffffff0| @33||+1&&| +0#0000e05#a8a8a8255@1|g+0#0000000#ffffff0| @33 +|~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|[+3#0000000&|N|o| |N|a|m|e|]| |[|+|]| @5|1|,|1| @11|A|l@1| |[+1&&|N|o| |N|a|m|e|]| |[|+|]| @5|1|,|1| @11|A|l@1 +| +0&&@74 diff --git a/src/testdir/dumps/Test_diff_bin_03.dump b/src/testdir/dumps/Test_diff_bin_03.dump new file mode 100644 index 000000000..a7d4cce51 --- /dev/null +++ b/src/testdir/dumps/Test_diff_bin_03.dump @@ -0,0 +1,20 @@ +| +0#0000e05#a8a8a8255@1>A+2#0000000#ff404010| +0&#ffd7ff255@33||+1&#ffffff0| +0#0000e05#a8a8a8255@1|a+2#0000000#ff404010| +0&#ffd7ff255@33 +| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0| @33||+1&&| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0| @33 +| +0#0000e05#a8a8a8255@1|c+0#0000000#ffd7ff255| @33||+1&#ffffff0| +0#0000e05#a8a8a8255@1|c+0#0000000#ffd7ff255|^+2#0000e05#ff404010|@| +0#0000000#ffd7ff255@31 +| +0#0000e05#a8a8a8255@1|d+0#0000000#ffffff0| @33||+1&&| +0#0000e05#a8a8a8255@1|d+0#0000000#ffffff0| @33 +| +0#0000e05#a8a8a8255@1|E+2#0000000#ff404010| +0&#ffd7ff255@33||+1&#ffffff0| +0#0000e05#a8a8a8255@1|e+2#0000000#ff404010| +0&#ffd7ff255@33 +| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0| @33||+1&&| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0| @33 +| +0#0000e05#a8a8a8255@1|g+0#0000000#ffffff0| @33||+1&&| +0#0000e05#a8a8a8255@1|g+0#0000000#ffffff0| @33 +|~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|[+3#0000000&|N|o| |N|a|m|e|]| |[|+|]| @5|1|,|1| @11|A|l@1| |[+1&&|N|o| |N|a|m|e|]| |[|+|]| @5|1|,|1| @11|A|l@1 +| +0&&@74 diff --git a/src/testdir/dumps/Test_diff_bin_04.dump b/src/testdir/dumps/Test_diff_bin_04.dump new file mode 100644 index 000000000..64ee1aca2 --- /dev/null +++ b/src/testdir/dumps/Test_diff_bin_04.dump @@ -0,0 +1,20 @@ +| +0#0000e05#a8a8a8255@1>A+0#0000000#ffffff0| @33||+1&&| +0#0000e05#a8a8a8255@1|a+0#0000000#ffffff0| @33 +| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0| @33||+1&&| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0| @33 +| +0#0000e05#a8a8a8255@1|c+0#0000000#ffd7ff255| @33||+1&#ffffff0| +0#0000e05#a8a8a8255@1|c+0#0000000#ffd7ff255|^+2#0000e05#ff404010|@| +0#0000000#ffd7ff255@31 +| +0#0000e05#a8a8a8255@1|d+0#0000000#ffffff0| @33||+1&&| +0#0000e05#a8a8a8255@1|d+0#0000000#ffffff0| @33 +| +0#0000e05#a8a8a8255@1|E+0#0000000#ffffff0| @33||+1&&| +0#0000e05#a8a8a8255@1|e+0#0000000#ffffff0| @33 +| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0| @33||+1&&| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0| @33 +| +0#0000e05#a8a8a8255@1|g+0#0000000#ffffff0| @33||+1&&| +0#0000e05#a8a8a8255@1|g+0#0000000#ffffff0| @33 +|~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|~| @35||+1#0000000&|~+0#4040ff13&| @35 +|[+3#0000000&|N|o| |N|a|m|e|]| |[|+|]| @5|1|,|1| @11|A|l@1| |[+1&&|N|o| |N|a|m|e|]| |[|+|]| @5|1|,|1| @11|A|l@1 +| +0&&@74 diff --git a/src/testdir/test_diffmode.vim b/src/testdir/test_diffmode.vim index d4c44ce37..e47928df8 100644 --- a/src/testdir/test_diffmode.vim +++ b/src/testdir/test_diffmode.vim @@ -1417,4 +1417,41 @@ func Test_diff_modify_chunks() %bw! endfunc +func Test_diff_binary() + CheckScreendump + + let content =<< trim END + call setline(1, ['a', 'b', "c\n", 'd', 'e', 'f', 'g']) + vnew + call setline(1, ['A', 'b', 'c', 'd', 'E', 'f', 'g']) + windo diffthis + wincmd p + norm! gg0 + redraw! + END + call writefile(content, 'Xtest_diff_bin') + let buf = RunVimInTerminal('-S Xtest_diff_bin', {}) + + " Test using internal diff + call VerifyScreenDump(buf, 'Test_diff_bin_01', {}) + + " Test using internal diff and case folding + call term_sendkeys(buf, ":set diffopt+=icase\<cr>") + call term_sendkeys(buf, "\<C-l>") + call VerifyScreenDump(buf, 'Test_diff_bin_02', {}) + " Test using external diff + call term_sendkeys(buf, ":set diffopt=filler\<cr>") + call term_sendkeys(buf, "\<C-l>") + call VerifyScreenDump(buf, 'Test_diff_bin_03', {}) + " Test using external diff and case folding + call term_sendkeys(buf, ":set diffopt=filler,icase\<cr>") + call term_sendkeys(buf, "\<C-l>") + call VerifyScreenDump(buf, 'Test_diff_bin_04', {}) + + " clean up + call StopVimInTerminal(buf) + call delete('Xtest_diff_bin') + set diffopt&vim +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index 90bd42294..60b1e5c92 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3925, +/**/ 3924, /**/ 3923, |