Skip to content

Commit ad5c178

Browse files
glacambrebrammool
authored andcommitted
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 #8197)
1 parent f5409db commit ad5c178

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/diff.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,10 +1007,12 @@ check_external_diff(diffio_T *diffio)
10071007

10081008
for (;;)
10091009
{
1010-
// There must be a line that contains "1c1".
1010+
// For normal diff there must be a line that contains
1011+
// "1c1". For unified diff "@@ -1 +1 @@".
10111012
if (vim_fgets(linebuf, LBUFLEN, fd))
10121013
break;
1013-
if (STRNCMP(linebuf, "1c1", 3) == 0)
1014+
if (STRNCMP(linebuf, "1c1", 3) == 0
1015+
|| STRNCMP(linebuf, "@@ -1 +1 @@", 11) == 0)
10141016
ok = TRUE;
10151017
}
10161018
fclose(fd);

src/testdir/test_diffmode.vim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,7 @@ func VerifyBoth(buf, dumpfile, extra)
796796

797797
" also test unified diff
798798
call term_sendkeys(a:buf, ":call SetupUnified()\<CR>:")
799+
call term_sendkeys(a:buf, ":redraw!\<CR>:")
799800
call VerifyScreenDump(a:buf, a:dumpfile, {}, 'unified')
800801
call term_sendkeys(a:buf, ":call StopUnified()\<CR>:")
801802
endfunc
@@ -817,10 +818,11 @@ func Test_diff_screen()
817818
func UnifiedDiffExpr()
818819
" Prepend some text to check diff type detection
819820
call writefile(['warning', ' message'], v:fname_out)
820-
silent exe '!diff -u ' .. v:fname_in .. ' ' .. v:fname_new .. '>>' .. v:fname_out
821+
silent exe '!diff -U0 ' .. v:fname_in .. ' ' .. v:fname_new .. '>>' .. v:fname_out
821822
endfunc
822823
func SetupUnified()
823824
set diffexpr=UnifiedDiffExpr()
825+
diffupdate
824826
endfunc
825827
func StopUnified()
826828
set diffexpr=
@@ -1218,4 +1220,5 @@ func Test_diff_filler_cursorcolumn()
12181220
call delete('Xtest_diff_cuc')
12191221
endfunc
12201222

1223+
12211224
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2880,
753755
/**/
754756
2879,
755757
/**/

0 commit comments

Comments
 (0)