vim-patch:8.2.2880: unified diff fails if actually used

Problem:    Unified diff fails if actually used.
Solution:   Invoke :diffupdate in the test.  Fix the check for working external
            diff. (Ghjuvan Lacambre, Christian Brabandt, closes vim/vim#8197)
ad5c178a19
This commit is contained in:
Jan Edmund Lazo
2021-05-24 12:19:25 -04:00
parent 0a653f7ab9
commit 6d932ccb1c
2 changed files with 8 additions and 3 deletions

View File

@@ -982,12 +982,14 @@ static int check_external_diff(diffio_T *diffio)
char_u linebuf[LBUFLEN]; char_u linebuf[LBUFLEN];
for (;;) { for (;;) {
// There must be a line that contains "1c1". // For normal diff there must be a line that contains
// "1c1". For unified diff "@@ -1 +1 @@".
if (vim_fgets(linebuf, LBUFLEN, fd)) { if (vim_fgets(linebuf, LBUFLEN, fd)) {
break; break;
} }
if (STRNCMP(linebuf, "1c1", 3) == 0) { if (STRNCMP(linebuf, "1c1", 3) == 0
|| STRNCMP(linebuf, "@@ -1 +1 @@", 11) == 0) {
ok = kTrue; ok = kTrue;
} }
} }

View File

@@ -802,6 +802,7 @@ func VerifyBoth(buf, dumpfile, extra)
" also test unified diff " also test unified diff
call term_sendkeys(a:buf, ":call SetupUnified()\<CR>:") call term_sendkeys(a:buf, ":call SetupUnified()\<CR>:")
call term_sendkeys(a:buf, ":redraw!\<CR>:")
call VerifyScreenDump(a:buf, a:dumpfile, {}, 'unified') call VerifyScreenDump(a:buf, a:dumpfile, {}, 'unified')
call term_sendkeys(a:buf, ":call StopUnified()\<CR>:") call term_sendkeys(a:buf, ":call StopUnified()\<CR>:")
endfunc endfunc
@@ -823,10 +824,11 @@ func Test_diff_screen()
func UnifiedDiffExpr() func UnifiedDiffExpr()
" Prepend some text to check diff type detection " Prepend some text to check diff type detection
call writefile(['warning', ' message'], v:fname_out) call writefile(['warning', ' message'], v:fname_out)
silent exe '!diff -u ' .. v:fname_in .. ' ' .. v:fname_new .. '>>' .. v:fname_out silent exe '!diff -U0 ' .. v:fname_in .. ' ' .. v:fname_new .. '>>' .. v:fname_out
endfunc endfunc
func SetupUnified() func SetupUnified()
set diffexpr=UnifiedDiffExpr() set diffexpr=UnifiedDiffExpr()
diffupdate
endfunc endfunc
func StopUnified() func StopUnified()
set diffexpr= set diffexpr=
@@ -1146,4 +1148,5 @@ func Test_diff_and_scroll()
set ls& set ls&
endfunc endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab