Skip to content

Commit af0da56

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents c9a5a7f + ba98fb5 commit af0da56

20 files changed

Lines changed: 181 additions & 56 deletions

src/buffer.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ close_buffer(
595595
if (buf->b_nwindows == 1)
596596
{
597597
++buf->b_locked;
598+
++buf->b_locked_split;
598599
if (apply_autocmds(EVENT_BUFWINLEAVE, buf->b_fname, buf->b_fname,
599600
FALSE, buf)
600601
&& !bufref_valid(&bufref))
@@ -605,6 +606,7 @@ close_buffer(
605606
return FALSE;
606607
}
607608
--buf->b_locked;
609+
--buf->b_locked_split;
608610
if (abort_if_last && one_window())
609611
// Autocommands made this the only window.
610612
goto aucmd_abort;
@@ -614,12 +616,14 @@ close_buffer(
614616
if (!unload_buf)
615617
{
616618
++buf->b_locked;
619+
++buf->b_locked_split;
617620
if (apply_autocmds(EVENT_BUFHIDDEN, buf->b_fname, buf->b_fname,
618621
FALSE, buf)
619622
&& !bufref_valid(&bufref))
620623
// Autocommands deleted the buffer.
621624
goto aucmd_abort;
622625
--buf->b_locked;
626+
--buf->b_locked_split;
623627
if (abort_if_last && one_window())
624628
// Autocommands made this the only window.
625629
goto aucmd_abort;
@@ -804,6 +808,7 @@ buf_freeall(buf_T *buf, int flags)
804808

805809
// Make sure the buffer isn't closed by autocommands.
806810
++buf->b_locked;
811+
++buf->b_locked_split;
807812
set_bufref(&bufref, buf);
808813
if (buf->b_ml.ml_mfp != NULL)
809814
{
@@ -830,6 +835,7 @@ buf_freeall(buf_T *buf, int flags)
830835
return;
831836
}
832837
--buf->b_locked;
838+
--buf->b_locked_split;
833839

834840
// If the buffer was in curwin and the window has changed, go back to that
835841
// window, if it still exists. This avoids that ":edit x" triggering a
@@ -1722,8 +1728,8 @@ set_curbuf(buf_T *buf, int action)
17221728
set_bufref(&prevbufref, prevbuf);
17231729
set_bufref(&newbufref, buf);
17241730

1725-
// Autocommands may delete the current buffer and/or the buffer we want to go
1726-
// to. In those cases don't close the buffer.
1731+
// Autocommands may delete the current buffer and/or the buffer we want to
1732+
// go to. In those cases don't close the buffer.
17271733
if (!apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf)
17281734
|| (bufref_valid(&prevbufref)
17291735
&& bufref_valid(&newbufref)

src/dict.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
945945
if (**arg != ':')
946946
{
947947
if (*skipwhite(*arg) == ':')
948-
semsg(_(e_no_white_space_allowed_before_str), ":");
948+
semsg(_(e_no_white_space_allowed_before_str_str), ":", *arg);
949949
else
950950
semsg(_(e_missing_dict_colon), *arg);
951951
clear_tv(&tvkey);
@@ -970,7 +970,7 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
970970
}
971971
if (vim9script && (*arg)[1] != NUL && !VIM_ISWHITE((*arg)[1]))
972972
{
973-
semsg(_(e_white_space_required_after_str), ":");
973+
semsg(_(e_white_space_required_after_str_str), ":", *arg);
974974
clear_tv(&tvkey);
975975
goto failret;
976976
}
@@ -1012,7 +1012,7 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
10121012
{
10131013
if (vim9script && (*arg)[1] != NUL && !VIM_ISWHITE((*arg)[1]))
10141014
{
1015-
semsg(_(e_white_space_required_after_str), ",");
1015+
semsg(_(e_white_space_required_after_str_str), ",", *arg);
10161016
goto failret;
10171017
}
10181018
*arg = skipwhite(*arg + 1);
@@ -1025,7 +1025,7 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
10251025
if (!had_comma)
10261026
{
10271027
if (**arg == ',')
1028-
semsg(_(e_no_white_space_allowed_before_str), ",");
1028+
semsg(_(e_no_white_space_allowed_before_str_str), ",", *arg);
10291029
else
10301030
semsg(_(e_missing_dict_comma), *arg);
10311031
goto failret;

src/errors.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ EXTERN char e_cannot_declare_a_register_str[]
173173
INIT(= N_("E1066: Cannot declare a register: %s"));
174174
EXTERN char e_separator_mismatch_str[]
175175
INIT(= N_("E1067: Separator mismatch: %s"));
176-
EXTERN char e_no_white_space_allowed_before_str[]
177-
INIT(= N_("E1068: No white space allowed before '%s'"));
178-
EXTERN char e_white_space_required_after_str[]
179-
INIT(= N_("E1069: White space required after '%s'"));
176+
EXTERN char e_no_white_space_allowed_before_str_str[]
177+
INIT(= N_("E1068: No white space allowed before '%s': %s"));
178+
EXTERN char e_white_space_required_after_str_str[]
179+
INIT(= N_("E1069: White space required after '%s': %s"));
180180
EXTERN char e_missing_from[]
181181
INIT(= N_("E1070: Missing \"from\""));
182182
EXTERN char e_invalid_string_after_from[]
@@ -353,3 +353,7 @@ EXTERN char e_missing_return_type[]
353353
INIT(= N_("E1157: Missing return type"));
354354
EXTERN char e_cannot_use_flatten_in_vim9_script[]
355355
INIT(= N_("E1158: Cannot use flatten() in Vim9 script"));
356+
EXTERN char e_cannot_split_window_when_closing_buffer[]
357+
INIT(= N_("E1159: Cannot split a window when closing the buffer"));
358+
EXTERN char e_cannot_use_default_for_variable_arguments[]
359+
INIT(= N_("E1160: Cannot use a default for variable arguments"));

src/ex_docmd.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5218,8 +5218,7 @@ ends_excmd2(char_u *cmd_start UNUSED, char_u *cmd)
52185218
return TRUE;
52195219
#ifdef FEAT_EVAL
52205220
if (in_vim9script())
5221-
return c == '#' && cmd[1] != '{'
5222-
&& (cmd == cmd_start || VIM_ISWHITE(cmd[-1]));
5221+
return c == '#' && (cmd == cmd_start || VIM_ISWHITE(cmd[-1]));
52235222
#endif
52245223
return c == '"';
52255224
}

src/filepath.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3360,7 +3360,10 @@ dos_expandpath(
33603360
if (p == NULL)
33613361
break; // out of memory
33623362

3363-
if (*wfb.cAlternateFileName == NUL)
3363+
// Do not use the alternate filename when the file name ends in '~',
3364+
// because it picks up backup files: short name for "foo.vim~" is
3365+
// "foo~1.vim", which matches "*.vim".
3366+
if (*wfb.cAlternateFileName == NUL || p[STRLEN(p) - 1] == '~')
33643367
p_alt = NULL;
33653368
else
33663369
p_alt = utf16_to_enc(wfb.cAlternateFileName, NULL);

src/list.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ eval_list(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int do_error)
13111311
{
13121312
if (vim9script && !IS_WHITE_OR_NUL((*arg)[1]) && (*arg)[1] != ']')
13131313
{
1314-
semsg(_(e_white_space_required_after_str), ",");
1314+
semsg(_(e_white_space_required_after_str_str), ",", *arg);
13151315
goto failret;
13161316
}
13171317
*arg = skipwhite(*arg + 1);
@@ -1328,7 +1328,8 @@ eval_list(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int do_error)
13281328
if (do_error)
13291329
{
13301330
if (**arg == ',')
1331-
semsg(_(e_no_white_space_allowed_before_str), ",");
1331+
semsg(_(e_no_white_space_allowed_before_str_str),
1332+
",", *arg);
13321333
else
13331334
semsg(_("E696: Missing comma in List: %s"), *arg);
13341335
}

src/popupwin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1941,7 +1941,7 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type)
19411941
buf->b_p_ul = -1; // no undo
19421942
buf->b_p_swf = FALSE; // no swap file
19431943
buf->b_p_bl = FALSE; // unlisted buffer
1944-
buf->b_locked = TRUE;
1944+
buf->b_locked = TRUE; // prevent deleting the buffer
19451945

19461946
// Avoid that 'buftype' is reset when this buffer is entered.
19471947
buf->b_p_initialized = TRUE;

src/scriptfile.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,9 @@ do_source(
13191319
}
13201320
// imports can be redefined once
13211321
mark_imports_for_reload(sid);
1322+
1323+
// reset version, "vim9script" may have been added or removed.
1324+
si->sn_version = 1;
13221325
}
13231326
else
13241327
{
@@ -1457,7 +1460,7 @@ do_source(
14571460
if (si->sn_save_cpo != NULL)
14581461
{
14591462
set_option_value((char_u *)"cpo", 0L, si->sn_save_cpo, 0);
1460-
CLEAR_POINTER(si->sn_save_cpo);
1463+
VIM_CLEAR(si->sn_save_cpo);
14611464
}
14621465

14631466
restore_funccal();

src/structs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2636,6 +2636,8 @@ struct file_buffer
26362636
int b_flags; // various BF_ flags
26372637
int b_locked; // Buffer is being closed or referenced, don't
26382638
// let autocommands wipe it out.
2639+
int b_locked_split; // Buffer is being closed, don't allow opening
2640+
// a new window with it.
26392641

26402642
/*
26412643
* b_ffname has the full path of the file (NULL for no name).

src/testdir/test_autocmd.vim

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2761,15 +2761,15 @@ endfunc
27612761

27622762
" Fuzzer found some strange combination that caused a crash.
27632763
func Test_autocmd_normal_mess()
2764-
" TODO: why does this hang on Windows?
2764+
" For unknown reason this hangs on MS-Windows
27652765
CheckNotMSWindows
27662766

27672767
augroup aucmd_normal_test
27682768
au BufLeave,BufWinLeave,BufHidden,BufUnload,BufDelete,BufWipeout * norm 7q/qc
27692769
augroup END
2770-
o4
2770+
call assert_fails('o4', 'E1159')
27712771
silent! H
2772-
e xx
2772+
call assert_fails('e xx', 'E1159')
27732773
normal G
27742774

27752775
augroup aucmd_normal_test
@@ -2778,6 +2778,9 @@ func Test_autocmd_normal_mess()
27782778
endfunc
27792779

27802780
func Test_autocmd_closing_cmdwin()
2781+
" For unknown reason this hangs on MS-Windows
2782+
CheckNotMSWindows
2783+
27812784
au BufWinLeave * nested q
27822785
call assert_fails("norm 7q?\n", 'E855:')
27832786

@@ -2791,8 +2794,8 @@ func Test_autocmd_vimgrep()
27912794
au QuickfixCmdPre,BufNew,BufDelete,BufReadCmd * sb
27922795
au QuickfixCmdPre,BufNew,BufDelete,BufReadCmd * q9
27932796
augroup END
2794-
" TODO: if this is executed directly valgrind reports errors
2795-
call assert_fails('lv?a?', 'E926:')
2797+
%bwipe!
2798+
call assert_fails('lv ?a? foo', 'E926:')
27962799

27972800
augroup aucmd_vimgrep
27982801
au!

0 commit comments

Comments
 (0)