Skip to content

Commit 78f80e2

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents c11c152 + 13c724f commit 78f80e2

14 files changed

Lines changed: 146 additions & 20 deletions

src/charset.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,10 @@ getvcol(
12961296
posptr = NULL; /* continue until the NUL */
12971297
else
12981298
{
1299+
/* Special check for an empty line, which can happen on exit, when
1300+
* ml_get_buf() always returns an empty string. */
1301+
if (*ptr == NUL)
1302+
pos->col = 0;
12991303
posptr = ptr + pos->col;
13001304
#ifdef FEAT_MBYTE
13011305
if (has_mbyte)

src/ex_cmds2.c

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3582,6 +3582,9 @@ add_pack_plugin(char_u *fname, void *cookie)
35823582
size_t afterlen = 0;
35833583
char_u *ffname = fix_fname(fname);
35843584
size_t fname_len;
3585+
char_u *buf = NULL;
3586+
char_u *rtp_ffname;
3587+
int match;
35853588

35863589
if (ffname == NULL)
35873590
return;
@@ -3606,26 +3609,28 @@ add_pack_plugin(char_u *fname, void *cookie)
36063609
/* Find "ffname" in "p_rtp", ignoring '/' vs '\' differences. */
36073610
fname_len = STRLEN(ffname);
36083611
insp = p_rtp;
3609-
for (;;)
3612+
buf = alloc(MAXPATHL);
3613+
if (buf == NULL)
3614+
goto theend;
3615+
while (*insp != NUL)
36103616
{
3611-
if (vim_fnamencmp(insp, ffname, fname_len) == 0)
3612-
break;
3613-
insp = vim_strchr(insp, ',');
3614-
if (insp == NULL)
3617+
copy_option_part(&insp, buf, MAXPATHL, ",");
3618+
add_pathsep(buf);
3619+
rtp_ffname = fix_fname(buf);
3620+
if (rtp_ffname == NULL)
3621+
goto theend;
3622+
match = vim_fnamencmp(rtp_ffname, ffname, fname_len) == 0;
3623+
vim_free(rtp_ffname);
3624+
if (match)
36153625
break;
3616-
++insp;
36173626
}
36183627

3619-
if (insp == NULL)
3628+
if (*insp == NUL)
36203629
/* not found, append at the end */
36213630
insp = p_rtp + STRLEN(p_rtp);
36223631
else
3623-
{
36243632
/* append after the matching directory. */
3625-
insp += STRLEN(ffname);
3626-
while (*insp != NUL && *insp != ',')
3627-
++insp;
3628-
}
3633+
--insp;
36293634
*p4 = c;
36303635

36313636
/* check if rtp/pack/name/start/name/after exists */
@@ -3635,7 +3640,8 @@ add_pack_plugin(char_u *fname, void *cookie)
36353640

36363641
oldlen = STRLEN(p_rtp);
36373642
addlen = STRLEN(ffname) + 1; /* add one for comma */
3638-
new_rtp = alloc((int)(oldlen + addlen + afterlen + 1)); /* add one for NUL */
3643+
new_rtp = alloc((int)(oldlen + addlen + afterlen + 1));
3644+
/* add one for NUL */
36393645
if (new_rtp == NULL)
36403646
goto theend;
36413647
keep = (int)(insp - p_rtp);
@@ -3689,6 +3695,7 @@ add_pack_plugin(char_u *fname, void *cookie)
36893695
}
36903696

36913697
theend:
3698+
vim_free(buf);
36923699
vim_free(ffname);
36933700
}
36943701

src/json.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
863863
&& cur_item != NULL)
864864
{
865865
top_item->jd_key = get_tv_string_buf_chk(cur_item, key_buf);
866-
if (top_item->jd_key == NULL || *top_item->jd_key == NUL)
866+
if (top_item->jd_key == NULL)
867867
{
868868
clear_tv(cur_item);
869869
EMSG(_(e_invarg));

src/option.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5043,7 +5043,7 @@ do_set(
50435043
if (flags & P_FLAGLIST)
50445044
{
50455045
/* Remove flags that appear twice. */
5046-
for (s = newval; *s; ++s)
5046+
for (s = newval; *s;)
50475047
{
50485048
/* if options have P_FLAGLIST and
50495049
* P_ONECOMMA such as 'whichwrap' */
@@ -5055,7 +5055,7 @@ do_set(
50555055
/* Remove the duplicated value and
50565056
* the next comma. */
50575057
STRMOVE(s, s + 2);
5058-
s -= 2;
5058+
continue;
50595059
}
50605060
}
50615061
else
@@ -5064,9 +5064,10 @@ do_set(
50645064
&& vim_strchr(s + 1, *s) != NULL)
50655065
{
50665066
STRMOVE(s, s + 1);
5067-
--s;
5067+
continue;
50685068
}
50695069
}
5070+
++s;
50705071
}
50715072
}
50725073

src/os_amiga.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,8 @@ mch_early_init(void)
889889
void
890890
mch_exit(int r)
891891
{
892+
exiting = TRUE;
893+
892894
if (raw_in) /* put terminal in 'normal' mode */
893895
{
894896
settmode(TMODE_COOK);

src/os_mswin.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ int _stricoll(char *a, char *b)
201201
void
202202
mch_exit(int r)
203203
{
204+
exiting = TRUE;
205+
204206
display_errors();
205207

206208
ml_close_all(TRUE); /* remove all memfiles */

src/os_win32.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2538,8 +2538,9 @@ mch_init(void)
25382538
void
25392539
mch_exit(int r)
25402540
{
2541-
stoptermcap();
2541+
exiting = TRUE;
25422542

2543+
stoptermcap();
25432544
if (g_fWindInitCalled)
25442545
settmode(TMODE_COOK);
25452546

src/testdir/test_functions.vim

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,39 +320,73 @@ func! Test_mode()
320320
normal! 3G
321321
exe "normal i\<F2>\<Esc>"
322322
call assert_equal('i-i', g:current_modes)
323+
" i_CTRL-P: Multiple matches
323324
exe "normal i\<C-G>uBa\<C-P>\<F2>\<Esc>u"
324325
call assert_equal('i-ic', g:current_modes)
326+
" i_CTRL-P: Single match
325327
exe "normal iBro\<C-P>\<F2>\<Esc>u"
326328
call assert_equal('i-ic', g:current_modes)
329+
" i_CTRL-X
327330
exe "normal iBa\<C-X>\<F2>\<Esc>u"
328331
call assert_equal('i-ix', g:current_modes)
332+
" i_CTRL-X CTRL-P: Multiple matches
329333
exe "normal iBa\<C-X>\<C-P>\<F2>\<Esc>u"
330334
call assert_equal('i-ic', g:current_modes)
335+
" i_CTRL-X CTRL-P: Single match
331336
exe "normal iBro\<C-X>\<C-P>\<F2>\<Esc>u"
332337
call assert_equal('i-ic', g:current_modes)
338+
" i_CTRL-X CTRL-P + CTRL-P: Single match
333339
exe "normal iBro\<C-X>\<C-P>\<C-P>\<F2>\<Esc>u"
334340
call assert_equal('i-ic', g:current_modes)
341+
" i_CTRL-X CTRL-L: Multiple matches
342+
exe "normal i\<C-X>\<C-L>\<F2>\<Esc>u"
343+
call assert_equal('i-ic', g:current_modes)
344+
" i_CTRL-X CTRL-L: Single match
345+
exe "normal iBlu\<C-X>\<C-L>\<F2>\<Esc>u"
346+
call assert_equal('i-ic', g:current_modes)
347+
" i_CTRL-P: No match
335348
exe "normal iCom\<C-P>\<F2>\<Esc>u"
336349
call assert_equal('i-ic', g:current_modes)
350+
" i_CTRL-X CTRL-P: No match
337351
exe "normal iCom\<C-X>\<C-P>\<F2>\<Esc>u"
338352
call assert_equal('i-ic', g:current_modes)
353+
" i_CTRL-X CTRL-L: No match
354+
exe "normal iabc\<C-X>\<C-L>\<F2>\<Esc>u"
355+
call assert_equal('i-ic', g:current_modes)
339356

357+
" R_CTRL-P: Multiple matches
340358
exe "normal RBa\<C-P>\<F2>\<Esc>u"
341359
call assert_equal('R-Rc', g:current_modes)
360+
" R_CTRL-P: Single match
342361
exe "normal RBro\<C-P>\<F2>\<Esc>u"
343362
call assert_equal('R-Rc', g:current_modes)
363+
" R_CTRL-X
344364
exe "normal RBa\<C-X>\<F2>\<Esc>u"
345365
call assert_equal('R-Rx', g:current_modes)
366+
" R_CTRL-X CTRL-P: Multiple matches
346367
exe "normal RBa\<C-X>\<C-P>\<F2>\<Esc>u"
347368
call assert_equal('R-Rc', g:current_modes)
369+
" R_CTRL-X CTRL-P: Single match
348370
exe "normal RBro\<C-X>\<C-P>\<F2>\<Esc>u"
349371
call assert_equal('R-Rc', g:current_modes)
372+
" R_CTRL-X CTRL-P + CTRL-P: Single match
350373
exe "normal RBro\<C-X>\<C-P>\<C-P>\<F2>\<Esc>u"
351374
call assert_equal('R-Rc', g:current_modes)
375+
" R_CTRL-X CTRL-L: Multiple matches
376+
exe "normal R\<C-X>\<C-L>\<F2>\<Esc>u"
377+
call assert_equal('R-Rc', g:current_modes)
378+
" R_CTRL-X CTRL-L: Single match
379+
exe "normal RBlu\<C-X>\<C-L>\<F2>\<Esc>u"
380+
call assert_equal('R-Rc', g:current_modes)
381+
" R_CTRL-P: No match
352382
exe "normal RCom\<C-P>\<F2>\<Esc>u"
353383
call assert_equal('R-Rc', g:current_modes)
384+
" R_CTRL-X CTRL-P: No match
354385
exe "normal RCom\<C-X>\<C-P>\<F2>\<Esc>u"
355386
call assert_equal('R-Rc', g:current_modes)
387+
" R_CTRL-X CTRL-L: No match
388+
exe "normal Rabc\<C-X>\<C-L>\<F2>\<Esc>u"
389+
call assert_equal('R-Rc', g:current_modes)
356390

357391
call assert_equal('n', mode(0))
358392
call assert_equal('n', mode(1))

src/testdir/test_gui.vim

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ if !has('gui') || ($DISPLAY == "" && !has('gui_running'))
44
finish
55
endif
66

7+
let s:x11_based_gui = has('gui_athena') || has('gui_motif')
8+
\ || has('gui_gtk2') || has('gui_gnome') || has('gui_gtk3')
9+
710
" For KDE set a font, empty 'guifont' may cause a hang.
811
func SetUp()
912
if has("gui_kde")
@@ -32,10 +35,23 @@ func Test_1_set_secure()
3235
call assert_equal(1, has('gui_running'))
3336
endfunc
3437

38+
func Test_getwinpos()
39+
call assert_match('Window position: X \d\+, Y \d\+', execute('winpos'))
40+
call assert_true(getwinposx() >= 0)
41+
call assert_true(getwinposy() >= 0)
42+
endfunction
43+
3544
func Test_shell_command()
3645
new
3746
r !echo hello
3847
call assert_equal('hello', substitute(getline(2), '\W', '', 'g'))
3948
bwipe!
40-
call assert_true(1, match(execute('winpos'), 'Window position: X \d\+, Y \d\+') >= 0)
4149
endfunc
50+
51+
func Test_windowid_variable()
52+
if s:x11_based_gui || has('win32')
53+
call assert_true(v:windowid > 0)
54+
else
55+
call assert_equal(0, v:windowid)
56+
endif
57+
endfunction

src/testdir/test_json.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ func Test_json_decode()
144144
call assert_equal(type(v:none), type(json_decode('')))
145145
call assert_equal("", json_decode('""'))
146146

147+
" empty key is OK
148+
call assert_equal({'': 'ok'}, json_decode('{"": "ok"}'))
149+
" but not twice
150+
call assert_fails("call json_decode('{\"\": \"ok\", \"\": \"bad\"}')", 'E938:')
151+
147152
call assert_equal({'n': 1}, json_decode('{"n":1,}'))
148153
call assert_fails("call json_decode(\"{'n':'1',}\")", 'E474:')
149154
call assert_fails("call json_decode(\"'n'\")", 'E474:')

0 commit comments

Comments
 (0)