Merge remote-tracking branch 'vim/master'

This commit is contained in:
ichizok
2021-02-08 15:18:19 +09:00
20 changed files with 181 additions and 56 deletions
+8 -2
View File
@@ -595,6 +595,7 @@ close_buffer(
if (buf->b_nwindows == 1)
{
++buf->b_locked;
++buf->b_locked_split;
if (apply_autocmds(EVENT_BUFWINLEAVE, buf->b_fname, buf->b_fname,
FALSE, buf)
&& !bufref_valid(&bufref))
@@ -605,6 +606,7 @@ aucmd_abort:
return FALSE;
}
--buf->b_locked;
--buf->b_locked_split;
if (abort_if_last && one_window())
// Autocommands made this the only window.
goto aucmd_abort;
@@ -614,12 +616,14 @@ aucmd_abort:
if (!unload_buf)
{
++buf->b_locked;
++buf->b_locked_split;
if (apply_autocmds(EVENT_BUFHIDDEN, buf->b_fname, buf->b_fname,
FALSE, buf)
&& !bufref_valid(&bufref))
// Autocommands deleted the buffer.
goto aucmd_abort;
--buf->b_locked;
--buf->b_locked_split;
if (abort_if_last && one_window())
// Autocommands made this the only window.
goto aucmd_abort;
@@ -804,6 +808,7 @@ buf_freeall(buf_T *buf, int flags)
// Make sure the buffer isn't closed by autocommands.
++buf->b_locked;
++buf->b_locked_split;
set_bufref(&bufref, buf);
if (buf->b_ml.ml_mfp != NULL)
{
@@ -830,6 +835,7 @@ buf_freeall(buf_T *buf, int flags)
return;
}
--buf->b_locked;
--buf->b_locked_split;
// If the buffer was in curwin and the window has changed, go back to that
// window, if it still exists. This avoids that ":edit x" triggering a
@@ -1722,8 +1728,8 @@ set_curbuf(buf_T *buf, int action)
set_bufref(&prevbufref, prevbuf);
set_bufref(&newbufref, buf);
// Autocommands may delete the current buffer and/or the buffer we want to go
// to. In those cases don't close the buffer.
// Autocommands may delete the current buffer and/or the buffer we want to
// go to. In those cases don't close the buffer.
if (!apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf)
|| (bufref_valid(&prevbufref)
&& bufref_valid(&newbufref)
+4 -4
View File
@@ -945,7 +945,7 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
if (**arg != ':')
{
if (*skipwhite(*arg) == ':')
semsg(_(e_no_white_space_allowed_before_str), ":");
semsg(_(e_no_white_space_allowed_before_str_str), ":", *arg);
else
semsg(_(e_missing_dict_colon), *arg);
clear_tv(&tvkey);
@@ -970,7 +970,7 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
}
if (vim9script && (*arg)[1] != NUL && !VIM_ISWHITE((*arg)[1]))
{
semsg(_(e_white_space_required_after_str), ":");
semsg(_(e_white_space_required_after_str_str), ":", *arg);
clear_tv(&tvkey);
goto failret;
}
@@ -1012,7 +1012,7 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
{
if (vim9script && (*arg)[1] != NUL && !VIM_ISWHITE((*arg)[1]))
{
semsg(_(e_white_space_required_after_str), ",");
semsg(_(e_white_space_required_after_str_str), ",", *arg);
goto failret;
}
*arg = skipwhite(*arg + 1);
@@ -1025,7 +1025,7 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal)
if (!had_comma)
{
if (**arg == ',')
semsg(_(e_no_white_space_allowed_before_str), ",");
semsg(_(e_no_white_space_allowed_before_str_str), ",", *arg);
else
semsg(_(e_missing_dict_comma), *arg);
goto failret;
+8 -4
View File
@@ -173,10 +173,10 @@ EXTERN char e_cannot_declare_a_register_str[]
INIT(= N_("E1066: Cannot declare a register: %s"));
EXTERN char e_separator_mismatch_str[]
INIT(= N_("E1067: Separator mismatch: %s"));
EXTERN char e_no_white_space_allowed_before_str[]
INIT(= N_("E1068: No white space allowed before '%s'"));
EXTERN char e_white_space_required_after_str[]
INIT(= N_("E1069: White space required after '%s'"));
EXTERN char e_no_white_space_allowed_before_str_str[]
INIT(= N_("E1068: No white space allowed before '%s': %s"));
EXTERN char e_white_space_required_after_str_str[]
INIT(= N_("E1069: White space required after '%s': %s"));
EXTERN char e_missing_from[]
INIT(= N_("E1070: Missing \"from\""));
EXTERN char e_invalid_string_after_from[]
@@ -353,3 +353,7 @@ EXTERN char e_missing_return_type[]
INIT(= N_("E1157: Missing return type"));
EXTERN char e_cannot_use_flatten_in_vim9_script[]
INIT(= N_("E1158: Cannot use flatten() in Vim9 script"));
EXTERN char e_cannot_split_window_when_closing_buffer[]
INIT(= N_("E1159: Cannot split a window when closing the buffer"));
EXTERN char e_cannot_use_default_for_variable_arguments[]
INIT(= N_("E1160: Cannot use a default for variable arguments"));
+1 -2
View File
@@ -5218,8 +5218,7 @@ ends_excmd2(char_u *cmd_start UNUSED, char_u *cmd)
return TRUE;
#ifdef FEAT_EVAL
if (in_vim9script())
return c == '#' && cmd[1] != '{'
&& (cmd == cmd_start || VIM_ISWHITE(cmd[-1]));
return c == '#' && (cmd == cmd_start || VIM_ISWHITE(cmd[-1]));
#endif
return c == '"';
}
+4 -1
View File
@@ -3360,7 +3360,10 @@ dos_expandpath(
if (p == NULL)
break; // out of memory
if (*wfb.cAlternateFileName == NUL)
// Do not use the alternate filename when the file name ends in '~',
// because it picks up backup files: short name for "foo.vim~" is
// "foo~1.vim", which matches "*.vim".
if (*wfb.cAlternateFileName == NUL || p[STRLEN(p) - 1] == '~')
p_alt = NULL;
else
p_alt = utf16_to_enc(wfb.cAlternateFileName, NULL);
+3 -2
View File
@@ -1311,7 +1311,7 @@ eval_list(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int do_error)
{
if (vim9script && !IS_WHITE_OR_NUL((*arg)[1]) && (*arg)[1] != ']')
{
semsg(_(e_white_space_required_after_str), ",");
semsg(_(e_white_space_required_after_str_str), ",", *arg);
goto failret;
}
*arg = skipwhite(*arg + 1);
@@ -1328,7 +1328,8 @@ eval_list(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int do_error)
if (do_error)
{
if (**arg == ',')
semsg(_(e_no_white_space_allowed_before_str), ",");
semsg(_(e_no_white_space_allowed_before_str_str),
",", *arg);
else
semsg(_("E696: Missing comma in List: %s"), *arg);
}
+1 -1
View File
@@ -1941,7 +1941,7 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type)
buf->b_p_ul = -1; // no undo
buf->b_p_swf = FALSE; // no swap file
buf->b_p_bl = FALSE; // unlisted buffer
buf->b_locked = TRUE;
buf->b_locked = TRUE; // prevent deleting the buffer
// Avoid that 'buftype' is reset when this buffer is entered.
buf->b_p_initialized = TRUE;
+4 -1
View File
@@ -1319,6 +1319,9 @@ do_source(
}
// imports can be redefined once
mark_imports_for_reload(sid);
// reset version, "vim9script" may have been added or removed.
si->sn_version = 1;
}
else
{
@@ -1457,7 +1460,7 @@ almosttheend:
if (si->sn_save_cpo != NULL)
{
set_option_value((char_u *)"cpo", 0L, si->sn_save_cpo, 0);
CLEAR_POINTER(si->sn_save_cpo);
VIM_CLEAR(si->sn_save_cpo);
}
restore_funccal();
+2
View File
@@ -2636,6 +2636,8 @@ struct file_buffer
int b_flags; // various BF_ flags
int b_locked; // Buffer is being closed or referenced, don't
// let autocommands wipe it out.
int b_locked_split; // Buffer is being closed, don't allow opening
// a new window with it.
/*
* b_ffname has the full path of the file (NULL for no name).
+8 -5
View File
@@ -2761,15 +2761,15 @@ endfunc
" Fuzzer found some strange combination that caused a crash.
func Test_autocmd_normal_mess()
" TODO: why does this hang on Windows?
" For unknown reason this hangs on MS-Windows
CheckNotMSWindows
augroup aucmd_normal_test
au BufLeave,BufWinLeave,BufHidden,BufUnload,BufDelete,BufWipeout * norm 7q/qc
augroup END
o4
call assert_fails('o4', 'E1159')
silent! H
e xx
call assert_fails('e xx', 'E1159')
normal G
augroup aucmd_normal_test
@@ -2778,6 +2778,9 @@ func Test_autocmd_normal_mess()
endfunc
func Test_autocmd_closing_cmdwin()
" For unknown reason this hangs on MS-Windows
CheckNotMSWindows
au BufWinLeave * nested q
call assert_fails("norm 7q?\n", 'E855:')
@@ -2791,8 +2794,8 @@ func Test_autocmd_vimgrep()
au QuickfixCmdPre,BufNew,BufDelete,BufReadCmd * sb
au QuickfixCmdPre,BufNew,BufDelete,BufReadCmd * q9
augroup END
" TODO: if this is executed directly valgrind reports errors
call assert_fails('lv?a?', 'E926:')
%bwipe!
call assert_fails('lv ?a? foo', 'E926:')
augroup aucmd_vimgrep
au!
+7 -5
View File
@@ -40,11 +40,13 @@ func Test_setbufline_getbufline()
call assert_equal([], getbufline(b, 6))
call assert_equal([], getbufline(b, 2, 1))
call setbufline(b, 2, [function('eval'), #{key: 123}, test_null_job()])
call assert_equal(["function('eval')",
\ "{'key': 123}",
\ "no process"],
\ getbufline(b, 2, 4))
if has('job')
call setbufline(b, 2, [function('eval'), #{key: 123}, test_null_job()])
call assert_equal(["function('eval')",
\ "{'key': 123}",
\ "no process"],
\ getbufline(b, 2, 4))
endif
exe "bwipe! " . b
endfunc
+7 -5
View File
@@ -824,11 +824,13 @@ def Test_set_get_bufline()
assert_equal([], getbufline(b, 6))
assert_equal([], getbufline(b, 2, 1))
setbufline(b, 2, [function('eval'), {key: 123}, test_null_job()])
assert_equal(["function('eval')",
"{'key': 123}",
"no process"],
getbufline(b, 2, 4))
if has('job')
setbufline(b, 2, [function('eval'), {key: 123}, test_null_job()])
assert_equal(["function('eval')",
"{'key': 123}",
"no process"],
getbufline(b, 2, 4))
endif
exe 'bwipe! ' .. b
END
+10
View File
@@ -781,6 +781,16 @@ def Test_call_def_varargs()
Func(1, 'a')
END
CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch')
lines =<< trim END
vim9script
def Func( # some comment
...l = []
)
echo l
enddef
END
CheckScriptFailure(lines, 'E1160:')
enddef
let s:value = ''
+39
View File
@@ -1743,6 +1743,21 @@ def Test_if_elseif_else_fails()
CheckDefFailure(['endif'], 'E580:')
CheckDefFailure(['if g:abool', 'elseif xxx'], 'E1001:')
CheckDefFailure(['if true', 'echo 1'], 'E171:')
var lines =<< trim END
var s = ''
if s = ''
endif
END
CheckDefFailure(lines, 'E488:')
lines =<< trim END
var s = ''
if s == ''
elseif s = ''
endif
END
CheckDefFailure(lines, 'E488:')
enddef
let g:bool_true = v:true
@@ -2190,6 +2205,10 @@ def Test_while_loop()
result ..= cnt .. '_'
endwhile
assert_equal('1_3_', result)
var s = ''
while s == 'x' #{comment}
endwhile
enddef
def Test_while_loop_fails()
@@ -2200,6 +2219,13 @@ def Test_while_loop_fails()
CheckDefFailure(['break'], 'E587:')
CheckDefFailure(['if true', 'break'], 'E587:')
CheckDefFailure(['while 1', 'echo 3'], 'E170:')
var lines =<< trim END
var s = ''
while s = ''
endwhile
END
CheckDefFailure(lines, 'E488:')
enddef
def Test_interrupt_loop()
@@ -3129,6 +3155,19 @@ def Test_restoring_cpo()
delete('Xsourced')
delete('Xclose')
delete('Xdone')
writefile(['vim9script'], 'XanotherScript')
set cpo=aABceFsMny>
edit XanotherScript
so %
assert_equal('aABceFsMny>', &cpo)
:1del
w
so %
assert_equal('aABceFsMny>', &cpo)
delete('XanotherScript')
set cpo&vim
enddef
+11 -6
View File
@@ -126,7 +126,7 @@ one_function_arg(
++p;
if (!skip && !VIM_ISWHITE(*p))
{
semsg(_(e_white_space_required_after_str), ":");
semsg(_(e_white_space_required_after_str_str), ":", p - 1);
return arg;
}
type = skipwhite(p);
@@ -241,6 +241,11 @@ get_function_args(
skip);
if (p == arg)
break;
if (*skipwhite(p) == '=')
{
emsg(_(e_cannot_use_default_for_variable_arguments));
break;
}
}
}
else
@@ -297,7 +302,7 @@ get_function_args(
if (!skip && in_vim9script()
&& !IS_WHITE_OR_NUL(*p) && *p != endchar)
{
semsg(_(e_white_space_required_after_str), ",");
semsg(_(e_white_space_required_after_str_str), ",", p - 1);
goto err_ret;
}
}
@@ -487,7 +492,7 @@ skip_arrow(
if (white_error != NULL && !VIM_ISWHITE(s[1]))
{
*white_error = TRUE;
semsg(_(e_white_space_required_after_str), ":");
semsg(_(e_white_space_required_after_str_str), ":", s);
return NULL;
}
s = skipwhite(s + 1);
@@ -873,7 +878,7 @@ get_func_tv(
{
if (*argp != ',' && *skipwhite(argp) == ',')
{
semsg(_(e_no_white_space_allowed_before_str), ",");
semsg(_(e_no_white_space_allowed_before_str_str), ",", argp);
ret = FAIL;
break;
}
@@ -884,7 +889,7 @@ get_func_tv(
break;
if (vim9script && !IS_WHITE_OR_NUL(argp[1]))
{
semsg(_(e_white_space_required_after_str), ",");
semsg(_(e_white_space_required_after_str_str), ",", argp);
ret = FAIL;
break;
}
@@ -3209,7 +3214,7 @@ define_function(exarg_T *eap, char_u *name_arg)
if ((vim9script || eap->cmdidx == CMD_def) && VIM_ISWHITE(p[-1]))
{
semsg(_(e_no_white_space_allowed_before_str), "(");
semsg(_(e_no_white_space_allowed_before_str_str), "(", p - 1);
goto ret_free;
}
+22
View File
@@ -765,6 +765,28 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2486,
/**/
2485,
/**/
2484,
/**/
2483,
/**/
2482,
/**/
2481,
/**/
2480,
/**/
2479,
/**/
2478,
/**/
2477,
/**/
2476,
/**/
2475,
/**/
+26 -11
View File
@@ -2800,14 +2800,14 @@ compile_arguments(char_u **arg, cctx_T *cctx, int *argcount)
if (*p != ',' && *skipwhite(p) == ',')
{
semsg(_(e_no_white_space_allowed_before_str), ",");
semsg(_(e_no_white_space_allowed_before_str_str), ",", p);
p = skipwhite(p);
}
if (*p == ',')
{
++p;
if (*p != NUL && !VIM_ISWHITE(*p))
semsg(_(e_white_space_required_after_str), ",");
semsg(_(e_white_space_required_after_str_str), ",", p - 1);
}
else
must_end = TRUE;
@@ -3055,7 +3055,7 @@ compile_list(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
}
if (*p == ',')
{
semsg(_(e_no_white_space_allowed_before_str), ",");
semsg(_(e_no_white_space_allowed_before_str_str), ",", p);
return FAIL;
}
if (*p == ']')
@@ -3073,7 +3073,7 @@ compile_list(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
++p;
if (*p != ']' && !IS_WHITE_OR_NUL(*p))
{
semsg(_(e_white_space_required_after_str), ",");
semsg(_(e_white_space_required_after_str_str), ",", p - 1);
return FAIL;
}
}
@@ -3234,7 +3234,7 @@ compile_dict(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
if (**arg != ':')
{
if (*skipwhite(*arg) == ':')
semsg(_(e_no_white_space_allowed_before_str), ":");
semsg(_(e_no_white_space_allowed_before_str_str), ":", *arg);
else
semsg(_(e_missing_dict_colon), *arg);
return FAIL;
@@ -3242,7 +3242,7 @@ compile_dict(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
whitep = *arg + 1;
if (!IS_WHITE_OR_NUL(*whitep))
{
semsg(_(e_white_space_required_after_str), ":");
semsg(_(e_white_space_required_after_str_str), ":", *arg);
return FAIL;
}
@@ -3273,16 +3273,16 @@ compile_dict(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
}
if (IS_WHITE_OR_NUL(*whitep))
{
semsg(_(e_no_white_space_allowed_before_str), ",");
semsg(_(e_no_white_space_allowed_before_str_str), ",", whitep);
return FAIL;
}
whitep = *arg + 1;
if (!IS_WHITE_OR_NUL(*whitep))
{
semsg(_(e_white_space_required_after_str), ",");
semsg(_(e_white_space_required_after_str_str), ",", *arg);
return FAIL;
}
*arg = skipwhite(*arg + 1);
*arg = skipwhite(whitep);
}
*arg = *arg + 1;
@@ -4270,7 +4270,7 @@ compile_expr7t(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
if (**arg != '>')
{
if (*skipwhite(*arg) == '>')
semsg(_(e_no_white_space_allowed_before_str), ">");
semsg(_(e_no_white_space_allowed_before_str_str), ">", *arg);
else
emsg(_(e_missing_gt));
return FAIL;
@@ -5711,7 +5711,7 @@ compile_lhs(
// parse optional type: "let var: type = expr"
if (!VIM_ISWHITE(var_end[1]))
{
semsg(_(e_white_space_required_after_str), ":");
semsg(_(e_white_space_required_after_str_str), ":", var_end);
return FAIL;
}
p = skipwhite(var_end + 1);
@@ -6701,6 +6701,11 @@ compile_if(char_u *arg, cctx_T *cctx)
clear_ppconst(&ppconst);
return NULL;
}
if (!ends_excmd2(arg, skipwhite(p)))
{
semsg(_(e_trailing_arg), p);
return NULL;
}
if (cctx->ctx_skip == SKIP_YES)
clear_ppconst(&ppconst);
else if (instr->ga_len == instr_count && ppconst.pp_used == 1)
@@ -6825,6 +6830,11 @@ compile_elseif(char_u *arg, cctx_T *cctx)
return NULL;
}
cctx->ctx_skip = save_skip;
if (!ends_excmd2(arg, skipwhite(p)))
{
semsg(_(e_trailing_arg), p);
return NULL;
}
if (scope->se_skip_save == SKIP_YES)
clear_ppconst(&ppconst);
else if (instr->ga_len == instr_count && ppconst.pp_used == 1)
@@ -7237,6 +7247,11 @@ compile_while(char_u *arg, cctx_T *cctx)
// compile "expr"
if (compile_expr0(&p, cctx) == FAIL)
return NULL;
if (!ends_excmd2(arg, skipwhite(p)))
{
semsg(_(e_trailing_arg), p);
return NULL;
}
if (bool_on_stack(cctx) == FAIL)
return FAIL;
+1 -1
View File
@@ -629,7 +629,7 @@ vim9_declare_scriptvar(exarg_T *eap, char_u *arg)
}
if (!VIM_ISWHITE(p[1]))
{
semsg(_(e_white_space_required_after_str), ":");
semsg(_(e_white_space_required_after_str_str), ":", p);
return arg + STRLEN(arg);
}
name = vim_strnsave(arg, p - arg);
+7 -4
View File
@@ -638,7 +638,7 @@ parse_type_member(
if (give_error)
{
if (*skipwhite(*arg) == '<')
semsg(_(e_no_white_space_allowed_before_str), "<");
semsg(_(e_no_white_space_allowed_before_str_str), "<", *arg);
else
emsg(_(e_missing_type));
}
@@ -779,7 +779,8 @@ parse_type(char_u **arg, garray_T *type_gap, int give_error)
if (*p != ',' && *skipwhite(p) == ',')
{
if (give_error)
semsg(_(e_no_white_space_allowed_before_str), ",");
semsg(_(e_no_white_space_allowed_before_str_str),
",", p);
return NULL;
}
if (*p == ',')
@@ -788,7 +789,8 @@ parse_type(char_u **arg, garray_T *type_gap, int give_error)
if (!VIM_ISWHITE(*p))
{
if (give_error)
semsg(_(e_white_space_required_after_str), ",");
semsg(_(e_white_space_required_after_str_str),
",", p - 1);
return NULL;
}
}
@@ -815,7 +817,8 @@ parse_type(char_u **arg, garray_T *type_gap, int give_error)
// parse return type
++*arg;
if (!VIM_ISWHITE(**arg) && give_error)
semsg(_(e_white_space_required_after_str), ":");
semsg(_(e_white_space_required_after_str_str),
":", *arg - 1);
*arg = skipwhite(*arg);
ret_type = parse_type(arg, type_gap, give_error);
if (ret_type == NULL)
+8 -2
View File
@@ -769,6 +769,11 @@ check_split_disallowed()
emsg(_("E242: Can't split a window while closing another"));
return FAIL;
}
if (curwin->w_buffer->b_locked_split)
{
emsg(_(e_cannot_split_window_when_closing_buffer));
return FAIL;
}
return OK;
}
@@ -793,6 +798,9 @@ win_split(int size, int flags)
if (ERROR_IF_ANY_POPUP_WINDOW)
return FAIL;
if (check_split_disallowed() == FAIL)
return FAIL;
// When the ":tab" modifier was used open a new tab page instead.
if (may_open_tabpage() == OK)
return OK;
@@ -804,8 +812,6 @@ win_split(int size, int flags)
emsg(_("E442: Can't split topleft and botright at the same time"));
return FAIL;
}
if (check_split_disallowed() == FAIL)
return FAIL;
// When creating the help window make a snapshot of the window layout.
// Otherwise clear the snapshot, it's now invalid.