Skip to content

Commit cfe8b45

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 3c543a1 + 79a213d commit cfe8b45

File tree

5 files changed

+200
-7
lines changed

5 files changed

+200
-7
lines changed

src/diff.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,8 @@ ex_diffoff(exarg_T *eap)
12441244
wp->w_p_wrap = wp->w_p_wrap_save;
12451245
#ifdef FEAT_FOLDING
12461246
free_string_option(wp->w_p_fdm);
1247-
wp->w_p_fdm = vim_strsave(wp->w_p_fdm_save);
1247+
wp->w_p_fdm = vim_strsave(
1248+
*wp->w_p_fdm_save ? wp->w_p_fdm_save : (char_u*)"manual");
12481249

12491250
if (wp->w_p_fdc == diff_foldcolumn)
12501251
wp->w_p_fdc = wp->w_p_fdc_save;

src/ex_docmd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10917,6 +10917,9 @@ eval_vars(
1091710917
result = strbuf;
1091810918
break;
1091910919
#endif
10920+
default:
10921+
result = (char_u *)""; /* avoid gcc warning */
10922+
break;
1092010923
}
1092110924

1092210925
resultlen = (int)STRLEN(result); /* length of new string */

src/quickfix.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ qf_parse_line(
919919
}
920920
if (fmt_ptr->flags == '+' && !qi->qf_multiscan) /* %+ */
921921
{
922-
if (linelen > fields->errmsglen)
922+
if (linelen >= fields->errmsglen)
923923
{
924924
/* linelen + null terminator */
925925
if ((fields->errmsg = vim_realloc(fields->errmsg,
@@ -934,7 +934,7 @@ qf_parse_line(
934934
if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL)
935935
continue;
936936
len = (int)(regmatch.endp[i] - regmatch.startp[i]);
937-
if (len > fields->errmsglen)
937+
if (len >= fields->errmsglen)
938938
{
939939
/* len + null terminator */
940940
if ((fields->errmsg = vim_realloc(fields->errmsg, len + 1))
@@ -1017,7 +1017,7 @@ qf_parse_line(
10171017
fields->namebuf[0] = NUL; /* no match found, remove file name */
10181018
fields->lnum = 0; /* don't jump to this line */
10191019
fields->valid = FALSE;
1020-
if (linelen > fields->errmsglen)
1020+
if (linelen >= fields->errmsglen)
10211021
{
10221022
/* linelen + null terminator */
10231023
if ((fields->errmsg = vim_realloc(fields->errmsg,

src/testdir/test_diffmode.vim

Lines changed: 186 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,69 @@ func Test_diffget_diffput()
199199
call assert_fails('diffget', 'E101:')
200200

201201
windo diffoff
202-
bwipe!
203-
bwipe!
204-
enew!
202+
%bwipe!
203+
endfunc
204+
205+
func Test_dp_do_buffer()
206+
e! one
207+
let bn1=bufnr('%')
208+
let l = range(60)
209+
call setline(1, l)
210+
diffthis
211+
212+
new two
213+
let l[10] = 'one'
214+
let l[20] = 'two'
215+
let l[30] = 'three'
216+
let l[40] = 'four'
217+
let l[50] = 'five'
218+
call setline(1, l)
219+
diffthis
220+
221+
" dp and do with invalid buffer number.
222+
11
223+
call assert_fails('norm 99999dp', 'E102:')
224+
call assert_fails('norm 99999do', 'E102:')
225+
call assert_fails('diffput non_existing_buffer', 'E94:')
226+
call assert_fails('diffget non_existing_buffer', 'E94:')
227+
228+
" dp and do with valid buffer number.
229+
call assert_equal('one', getline('.'))
230+
exe 'norm ' . bn1 . 'do'
231+
call assert_equal('10', getline('.'))
232+
21
233+
call assert_equal('two', getline('.'))
234+
diffget one
235+
call assert_equal('20', getline('.'))
236+
237+
31
238+
exe 'norm ' . bn1 . 'dp'
239+
41
240+
diffput one
241+
wincmd w
242+
31
243+
call assert_equal('three', getline('.'))
244+
41
245+
call assert_equal('four', getline('.'))
246+
247+
" dp and do with buffer number which is not in diff mode.
248+
new not_in_diff_mode
249+
let bn3=bufnr('%')
250+
wincmd w
251+
51
252+
call assert_fails('exe "norm" . bn3 . "dp"', 'E103:')
253+
call assert_fails('exe "norm" . bn3 . "do"', 'E103:')
254+
call assert_fails('diffput not_in_diff_mode', 'E94:')
255+
call assert_fails('diffget not_in_diff_mode', 'E94:')
256+
257+
windo diffoff
258+
%bwipe!
205259
endfunc
206260

207261
func Test_diffoff()
208262
enew!
209263
call setline(1, ['Two', 'Three'])
264+
redraw
210265
let normattr = screenattr(1, 1)
211266
diffthis
212267
botright vert new
@@ -221,10 +276,107 @@ func Test_diffoff()
221276
bwipe!
222277
endfunc
223278

279+
func Test_diffopt_icase()
280+
set diffopt=icase,foldcolumn:0
281+
282+
e one
283+
call setline(1, ['One', 'Two', 'Three', 'Four'])
284+
redraw
285+
let normattr = screenattr(1, 1)
286+
diffthis
287+
288+
botright vert new two
289+
call setline(1, ['one', 'TWO', 'Three ', 'Four'])
290+
diffthis
291+
292+
redraw
293+
call assert_equal(normattr, screenattr(1, 1))
294+
call assert_equal(normattr, screenattr(2, 1))
295+
call assert_notequal(normattr, screenattr(3, 1))
296+
call assert_equal(normattr, screenattr(4, 1))
297+
298+
diffoff!
299+
%bwipe!
300+
set diffopt&
301+
endfunc
302+
303+
func Test_diffopt_iwhite()
304+
set diffopt=iwhite,foldcolumn:0
305+
306+
e one
307+
" Difference in trailing spaces should be ignored,
308+
" but not other space differences.
309+
call setline(1, ["One \t", 'Two', 'Three', 'Four'])
310+
redraw
311+
let normattr = screenattr(1, 1)
312+
diffthis
313+
314+
botright vert new two
315+
call setline(1, ["One\t ", "Two\t ", 'Three', ' Four'])
316+
diffthis
317+
318+
redraw
319+
call assert_equal(normattr, screenattr(1, 1))
320+
call assert_equal(normattr, screenattr(2, 1))
321+
call assert_equal(normattr, screenattr(3, 1))
322+
call assert_notequal(normattr, screenattr(4, 1))
323+
324+
diffoff!
325+
%bwipe!
326+
set diffopt&
327+
endfunc
328+
329+
func Test_diffopt_context()
330+
enew!
331+
call setline(1, ['1', '2', '3', '4', '5', '6', '7'])
332+
diffthis
333+
new
334+
call setline(1, ['1', '2', '3', '4', '5x', '6', '7'])
335+
diffthis
336+
337+
set diffopt=context:2
338+
call assert_equal('+-- 2 lines: 1', foldtextresult(1))
339+
set diffopt=context:1
340+
call assert_equal('+-- 3 lines: 1', foldtextresult(1))
341+
342+
diffoff!
343+
%bwipe!
344+
set diffopt&
345+
endfunc
346+
347+
func Test_diffopt_horizontal()
348+
set diffopt=horizontal
349+
diffsplit
350+
351+
call assert_equal(&columns, winwidth(1))
352+
call assert_equal(&columns, winwidth(2))
353+
call assert_equal(&lines, winheight(1) + winheight(2) + 3)
354+
call assert_inrange(0, 1, winheight(1) - winheight(2))
355+
356+
set diffopt&
357+
diffoff!
358+
%bwipe
359+
endfunc
360+
361+
func Test_diffopt_vertical()
362+
set diffopt=vertical
363+
diffsplit
364+
365+
call assert_equal(&lines - 2, winheight(1))
366+
call assert_equal(&lines - 2, winheight(2))
367+
call assert_equal(&columns, winwidth(1) + winwidth(2) + 1)
368+
call assert_inrange(0, 1, winwidth(1) - winwidth(2))
369+
370+
set diffopt&
371+
diffoff!
372+
%bwipe
373+
endfunc
374+
224375
func Test_diffoff_hidden()
225376
set diffopt=filler,foldcolumn:0
226377
e! one
227378
call setline(1, ['Two', 'Three'])
379+
redraw
228380
let normattr = screenattr(1, 1)
229381
diffthis
230382
botright vert new two
@@ -296,6 +448,37 @@ func Test_diff_move_to()
296448
%bwipe!
297449
endfunc
298450

451+
func Test_diffexpr()
452+
if !executable('diff')
453+
return
454+
endif
455+
456+
func DiffExpr()
457+
silent exe '!diff ' . v:fname_in . ' ' . v:fname_new . '>' . v:fname_out
458+
endfunc
459+
set diffexpr=DiffExpr()
460+
set diffopt=foldcolumn:0
461+
462+
enew!
463+
call setline(1, ['one', 'two', 'three'])
464+
redraw
465+
let normattr = screenattr(1, 1)
466+
diffthis
467+
468+
botright vert new
469+
call setline(1, ['one', 'two', 'three.'])
470+
diffthis
471+
472+
redraw
473+
call assert_equal(normattr, screenattr(1, 1))
474+
call assert_equal(normattr, screenattr(2, 1))
475+
call assert_notequal(normattr, screenattr(3, 1))
476+
477+
diffoff!
478+
%bwipe!
479+
set diffexpr& diffopt&
480+
endfunc
481+
299482
func Test_diffpatch()
300483
" The patch program on MS-Windows may fail or hang.
301484
if !executable('patch') || !has('unix')

src/version.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,12 @@ static char *(features[]) =
779779

780780
static int included_patches[] =
781781
{ /* Add new patch number below this line */
782+
/**/
783+
599,
784+
/**/
785+
598,
786+
/**/
787+
597,
782788
/**/
783789
596,
784790
/**/

0 commit comments

Comments
 (0)