Skip to content

Commit b6fc728

Browse files
committed
patch 8.1.0562: parsing of 'diffopt' is slightly wrong
Problem: Parsing of 'diffopt' is slightly wrong. Solution: Fix the parsing and add a test. (Jason Franklin, Christian Brabandt)
1 parent 9719568 commit b6fc728

6 files changed

Lines changed: 21 additions & 7 deletions

File tree

src/diff.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2173,6 +2173,7 @@ diffopt_changed(void)
21732173
int diff_flags_new = 0;
21742174
int diff_foldcolumn_new = 2;
21752175
long diff_algorithm_new = 0;
2176+
long diff_indent_heuristic = 0;
21762177
tabpage_T *tp;
21772178

21782179
p = p_dip;
@@ -2236,7 +2237,7 @@ diffopt_changed(void)
22362237
else if (STRNCMP(p, "indent-heuristic", 16) == 0)
22372238
{
22382239
p += 16;
2239-
diff_algorithm_new |= XDF_INDENT_HEURISTIC;
2240+
diff_indent_heuristic = XDF_INDENT_HEURISTIC;
22402241
}
22412242
else if (STRNCMP(p, "internal", 8) == 0)
22422243
{
@@ -2276,6 +2277,8 @@ diffopt_changed(void)
22762277
++p;
22772278
}
22782279

2280+
diff_algorithm_new |= diff_indent_heuristic;
2281+
22792282
/* Can't have both "horizontal" and "vertical". */
22802283
if ((diff_flags_new & DIFF_HORIZONTAL) && (diff_flags_new & DIFF_VERTICAL))
22812284
return FAIL;

src/testdir/dumps/Test_diff_09.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@3|{| @29||+1&&| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@3|{| @29
1818
| +0#0000e05#a8a8a8255@1| +0#0000000#5fd7ff255@7|p|r|i|n|t|f|(|"|Y|o|u|r| |a|n|s|w|e|r| |i|s|:| |"|)|;||+1&#ffffff0| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34
1919
|X+3#0000000#ffffff0|f|i|l|e|1| @12|1|,|1| @11|T|o|p| |X+1&&|f|i|l|e|2| @12|1|,|1| @11|T|o|p
20-
|:+0&&|s|e|t| |d|i|f@1|o|p|t|+|=|a|l|g|o|r|i|t|h|m|:|p|a|t|i|e|n|c|e| @42
20+
|:+0&&|s|e|t| |d|i|f@1|o|p|t|+|=|a|l|g|o|r|i|t|h|m|:|h|i|s|t|o|g|r|a|m| @41

src/testdir/dumps/Test_diff_11.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
| +0#0000e05#a8a8a8255@1|~+0#4040ff13#ffffff0| @33||+1#0000000&| +0#0000e05#a8a8a8255@1|~+0#4040ff13#ffffff0| @33
1818
| +0#0000e05#a8a8a8255@1|~+0#4040ff13#ffffff0| @33||+1#0000000&| +0#0000e05#a8a8a8255@1|~+0#4040ff13#ffffff0| @33
1919
|X+3#0000000&|f|i|l|e|1| @12|1|,|0|-|1| @9|A|l@1| |X+1&&|f|i|l|e|2| @12|1|,|0|-|1| @9|A|l@1
20-
|:+0&&|s|e|t| |d|i|f@1|o|p|t|+|=|i|n|d|e|n|t|-|h|e|u|r|i|s|t|i|c| @44
20+
|:+0&&| @73

src/testdir/screendump.vim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ func VerifyScreenDump(buf, filename, options, ...)
103103

104104
let i = 0
105105
while 1
106+
" leave some time for updating the original window
107+
sleep 10m
106108
call delete(testfile)
107109
call term_dumpwrite(a:buf, testfile, a:options)
108110
if readfile(reference) == readfile(testfile)
@@ -113,12 +115,11 @@ func VerifyScreenDump(buf, filename, options, ...)
113115
" Leave the test file around for inspection.
114116
let msg = 'See dump file difference: call term_dumpdiff("' . testfile . '", "' . reference . '")'
115117
if a:0 == 1
116-
let msg = a:1 . ': ' . msg
118+
let msg = a:1 . ': ' . msg
117119
endif
118120
call assert_report(msg)
119121
return 1
120122
endif
121-
sleep 10m
122123
let i += 1
123124
endwhile
124125
return 0

src/testdir/test_diffmode.vim

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,8 +813,16 @@ func Test_diff_screen()
813813
call term_sendkeys(buf, ":set diffopt+=internal\<cr>")
814814
call VerifyScreenDump(buf, 'Test_diff_10', {})
815815

816-
call term_sendkeys(buf, ":set diffopt+=indent-heuristic\<cr>")
817-
call VerifyScreenDump(buf, 'Test_diff_11', {})
816+
" Leave trailing : at commandline!
817+
call term_sendkeys(buf, ":set diffopt+=indent-heuristic\<cr>:\<cr>")
818+
call VerifyScreenDump(buf, 'Test_diff_11', {}, 'one')
819+
" shouldn't matter, if indent-algorithm comes before or after the algorithm
820+
call term_sendkeys(buf, ":set diffopt&\<cr>")
821+
call term_sendkeys(buf, ":set diffopt+=indent-heuristic,algorithm:patience\<cr>:\<cr>")
822+
call VerifyScreenDump(buf, 'Test_diff_11', {}, 'two')
823+
call term_sendkeys(buf, ":set diffopt&\<cr>")
824+
call term_sendkeys(buf, ":set diffopt+=algorithm:patience,indent-heuristic\<cr>:\<cr>")
825+
call VerifyScreenDump(buf, 'Test_diff_11', {}, 'three')
818826

819827
" Test 12: diff the same file
820828
call WriteDiffFiles(buf, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])

src/version.c

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

793793
static int included_patches[] =
794794
{ /* Add new patch number below this line */
795+
/**/
796+
562,
795797
/**/
796798
561,
797799
/**/

0 commit comments

Comments
 (0)