diff src/testdir/test_diffmode.vim @ 26794:83a99f08d1e8 v8.2.3925

patch 8.2.3925: diff mode confused by NUL bytes Commit: https://github.com/vim/vim/commit/06f6095623cfcc72da08748c058d13b465652fd4 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Dec 28 18:30:05 2021 +0000 patch 8.2.3925: diff mode confused by NUL bytes Problem: Diff mode confused by NUL bytes. Solution: Handle NUL bytes differently. (Christian Brabandt, closes https://github.com/vim/vim/issues/9421, closes #9418)
author Bram Moolenaar <Bram@vim.org>
date Tue, 28 Dec 2021 19:45:04 +0100
parents c2c40cefc17b
children 421d082c8f09
line wrap: on
line diff
--- 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