Merge pull request #19669 from zeertzjq/vim-8.2.1278

vim-patch:8.2.{1278,1280,1281}: error message improvements
This commit is contained in:
zeertzjq 2022-08-07 15:22:48 +08:00 committed by GitHub
commit fea15adad3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 88 additions and 327 deletions

View File

@ -969,7 +969,7 @@ char *do_bufdel(int command, char *arg, int addr_count, int start_bnr, int end_b
} else { } else {
if (addr_count == 2) { if (addr_count == 2) {
if (*arg) { // both range and argument is not allowed if (*arg) { // both range and argument is not allowed
return _(e_trailing); return ex_errmsg(e_trailing_arg, arg);
} }
bnr = start_bnr; bnr = start_bnr;
} else { // addr_count == 1 } else { // addr_count == 1

View File

@ -544,9 +544,9 @@ int var_redir_start(char *name, int append)
clear_lval(redir_lval); clear_lval(redir_lval);
if (redir_endp != NULL && *redir_endp != NUL) { if (redir_endp != NULL && *redir_endp != NUL) {
// Trailing characters are present after the variable name // Trailing characters are present after the variable name
emsg(_(e_trailing)); semsg(_(e_trailing_arg), redir_endp);
} else { } else {
emsg(_(e_invarg)); semsg(_(e_invarg2), name);
} }
redir_endp = NULL; // don't store a value, only cleanup redir_endp = NULL; // don't store a value, only cleanup
var_redir_stop(); var_redir_stop();
@ -1326,7 +1326,7 @@ char *get_lval(char *const name, typval_T *const rettv, lval_T *const lp, const
// Don't expand the name when we already know there is an error. // Don't expand the name when we already know there is an error.
if (unlet && !ascii_iswhite(*p) && !ends_excmd(*p) if (unlet && !ascii_iswhite(*p) && !ends_excmd(*p)
&& *p != '[' && *p != '.') { && *p != '[' && *p != '.') {
emsg(_(e_trailing)); semsg(_(e_trailing_arg), p);
return NULL; return NULL;
} }

View File

@ -1839,7 +1839,7 @@ static void f_eval(typval_T *argvars, typval_T *rettv, FunPtr fptr)
rettv->v_type = VAR_NUMBER; rettv->v_type = VAR_NUMBER;
rettv->vval.v_number = 0; rettv->vval.v_number = 0;
} else if (*s != NUL) { } else if (*s != NUL) {
emsg(_(e_trailing)); semsg(_(e_trailing_arg), s);
} }
} }
@ -4702,7 +4702,7 @@ static void f_islocked(typval_T *argvars, typval_T *rettv, FunPtr fptr)
FNE_CHECK_START); FNE_CHECK_START);
if (end != NULL && lv.ll_name != NULL) { if (end != NULL && lv.ll_name != NULL) {
if (*end != NUL) { if (*end != NUL) {
emsg(_(e_trailing)); semsg(_(e_trailing_arg), end);
} else { } else {
if (lv.ll_tv == NULL) { if (lv.ll_tv == NULL) {
di = find_var(lv.ll_name, lv.ll_name_len, NULL, true); di = find_var(lv.ll_name, lv.ll_name_len, NULL, true);

View File

@ -2039,7 +2039,7 @@ void ex_function(exarg_T *eap)
// //
if (!paren) { if (!paren) {
if (!ends_excmd(*skipwhite((char *)p))) { if (!ends_excmd(*skipwhite((char *)p))) {
emsg(_(e_trailing)); semsg(_(e_trailing_arg), p);
goto ret_free; goto ret_free;
} }
eap->nextcmd = (char *)check_nextcmd(p); eap->nextcmd = (char *)check_nextcmd(p);
@ -2163,7 +2163,7 @@ void ex_function(exarg_T *eap)
if (*p == '\n') { if (*p == '\n') {
line_arg = p + 1; line_arg = p + 1;
} else if (*p != NUL && *p != '"' && !eap->skip && !did_emsg) { } else if (*p != NUL && *p != '"' && !eap->skip && !did_emsg) {
emsg(_(e_trailing)); semsg(_(e_trailing_arg), p);
} }
/* /*
@ -2703,7 +2703,7 @@ void ex_delfunction(exarg_T *eap)
} }
if (!ends_excmd(*skipwhite((char *)p))) { if (!ends_excmd(*skipwhite((char *)p))) {
xfree(name); xfree(name);
emsg(_(e_trailing)); semsg(_(e_trailing_arg), p);
return; return;
} }
eap->nextcmd = (char *)check_nextcmd(p); eap->nextcmd = (char *)check_nextcmd(p);
@ -3021,7 +3021,7 @@ void ex_call(exarg_T *eap)
if (!ends_excmd(*arg)) { if (!ends_excmd(*arg)) {
if (!failed && !aborting()) { if (!failed && !aborting()) {
emsg_severe = true; emsg_severe = true;
emsg(_(e_trailing)); semsg(_(e_trailing_arg), arg);
} }
} else { } else {
eap->nextcmd = (char *)check_nextcmd(arg); eap->nextcmd = (char *)check_nextcmd(arg);

View File

@ -80,7 +80,7 @@ static list_T *heredoc_get(exarg_T *eap, char *cmd)
marker = skipwhite(cmd); marker = skipwhite(cmd);
p = (char *)skiptowhite((char_u *)marker); p = (char *)skiptowhite((char_u *)marker);
if (*skipwhite(p) != NUL && *skipwhite(p) != '"') { if (*skipwhite(p) != NUL && *skipwhite(p) != '"') {
emsg(_(e_trailing)); semsg(_(e_trailing_arg), p);
return NULL; return NULL;
} }
*p = NUL; *p = NUL;
@ -460,7 +460,7 @@ static const char *list_arg_vars(exarg_T *eap, const char *arg, int *first)
arg = find_name_end(arg, NULL, NULL, FNE_INCL_BR | FNE_CHECK_START); arg = find_name_end(arg, NULL, NULL, FNE_INCL_BR | FNE_CHECK_START);
if (!ascii_iswhite(*arg) && !ends_excmd(*arg)) { if (!ascii_iswhite(*arg) && !ends_excmd(*arg)) {
emsg_severe = true; emsg_severe = true;
emsg(_(e_trailing)); semsg(_(e_trailing_arg), arg);
break; break;
} }
} else { } else {
@ -808,7 +808,7 @@ static void ex_unletlock(exarg_T *eap, char *argstart, int deep, ex_unletlock_ca
|| (!ascii_iswhite(*name_end) && !ends_excmd(*name_end))) { || (!ascii_iswhite(*name_end) && !ends_excmd(*name_end))) {
if (name_end != NULL) { if (name_end != NULL) {
emsg_severe = true; emsg_severe = true;
emsg(_(e_trailing)); semsg(_(e_trailing_arg), name_end);
} }
if (!(eap->skip || error)) { if (!(eap->skip || error)) {
clear_lval(&lv); clear_lval(&lv);

View File

@ -3616,7 +3616,7 @@ static int do_sub(exarg_T *eap, proftime_T timeout, long cmdpreview_ns, handle_T
if (*cmd && *cmd != '"') { // if not end-of-line or comment if (*cmd && *cmd != '"') { // if not end-of-line or comment
eap->nextcmd = (char *)check_nextcmd((char_u *)cmd); eap->nextcmd = (char *)check_nextcmd((char_u *)cmd);
if (eap->nextcmd == NULL) { if (eap->nextcmd == NULL) {
emsg(_(e_trailing)); semsg(_(e_trailing_arg), cmd);
return 0; return 0;
} }
} }

View File

@ -1635,7 +1635,7 @@ static int execute_cmd0(int *retv, exarg_T *eap, char **errormsg, bool preview)
(cmdnames[eap->cmdidx].cmd_func)(eap); (cmdnames[eap->cmdidx].cmd_func)(eap);
} }
if (eap->errmsg != NULL) { if (eap->errmsg != NULL) {
*errormsg = _(eap->errmsg); *errormsg = eap->errmsg;
} }
} }
@ -2266,7 +2266,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
if (!ni && !(ea.argt & EX_EXTRA) && *ea.arg != NUL if (!ni && !(ea.argt & EX_EXTRA) && *ea.arg != NUL
&& *ea.arg != '"' && (*ea.arg != '|' || (ea.argt & EX_TRLBAR) == 0)) { && *ea.arg != '"' && (*ea.arg != '|' || (ea.argt & EX_TRLBAR) == 0)) {
// no arguments allowed but there is something // no arguments allowed but there is something
errormsg = _(e_trailing); errormsg = ex_errmsg(e_trailing_arg, ea.arg);
goto doend; goto doend;
} }
@ -4381,7 +4381,7 @@ static void get_flags(exarg_T *eap)
void ex_ni(exarg_T *eap) void ex_ni(exarg_T *eap)
{ {
if (!eap->skip) { if (!eap->skip) {
eap->errmsg = N_("E319: The command is not available in this version"); eap->errmsg = _("E319: The command is not available in this version");
} }
} }
@ -5018,7 +5018,7 @@ static int get_tabpage_arg(exarg_T *eap)
} else if (p == p_save || *p_save == '-' || *p != NUL } else if (p == p_save || *p_save == '-' || *p != NUL
|| tab_number > LAST_TAB_NR) { || tab_number > LAST_TAB_NR) {
// No numbers as argument. // No numbers as argument.
eap->errmsg = e_invarg; eap->errmsg = ex_errmsg(e_invarg2, eap->arg);
goto theend; goto theend;
} }
} else { } else {
@ -5026,20 +5026,20 @@ static int get_tabpage_arg(exarg_T *eap)
tab_number = 1; tab_number = 1;
} else if (p == p_save || *p_save == '-' || *p != NUL || tab_number == 0) { } else if (p == p_save || *p_save == '-' || *p != NUL || tab_number == 0) {
// No numbers as argument. // No numbers as argument.
eap->errmsg = e_invarg; eap->errmsg = ex_errmsg(e_invarg2, eap->arg);
goto theend; goto theend;
} }
tab_number = tab_number * relative + tabpage_index(curtab); tab_number = tab_number * relative + tabpage_index(curtab);
if (!unaccept_arg0 && relative == -1) { if (!unaccept_arg0 && relative == -1) {
--tab_number; tab_number--;
} }
} }
if (tab_number < unaccept_arg0 || tab_number > LAST_TAB_NR) { if (tab_number < unaccept_arg0 || tab_number > LAST_TAB_NR) {
eap->errmsg = e_invarg; eap->errmsg = ex_errmsg(e_invarg2, eap->arg);
} }
} else if (eap->addr_count > 0) { } else if (eap->addr_count > 0) {
if (unaccept_arg0 && eap->line2 == 0) { if (unaccept_arg0 && eap->line2 == 0) {
eap->errmsg = e_invrange; eap->errmsg = _(e_invrange);
tab_number = 0; tab_number = 0;
} else { } else {
tab_number = (int)eap->line2; tab_number = (int)eap->line2;
@ -5048,7 +5048,7 @@ static int get_tabpage_arg(exarg_T *eap)
if (!unaccept_arg0 && *cmdp == '-') { if (!unaccept_arg0 && *cmdp == '-') {
tab_number--; tab_number--;
if (tab_number < unaccept_arg0) { if (tab_number < unaccept_arg0) {
eap->errmsg = e_invarg; eap->errmsg = _(e_invrange);
} }
} }
} }
@ -5078,7 +5078,7 @@ static void ex_autocmd(exarg_T *eap)
// directory for security reasons. // directory for security reasons.
if (secure) { if (secure) {
secure = 2; secure = 2;
eap->errmsg = e_curdir; eap->errmsg = _(e_curdir);
} else if (eap->cmdidx == CMD_autocmd) { } else if (eap->cmdidx == CMD_autocmd) {
do_autocmd(eap->arg, eap->forceit); do_autocmd(eap->arg, eap->forceit);
} else { } else {
@ -5119,7 +5119,7 @@ static void ex_bunload(exarg_T *eap)
static void ex_buffer(exarg_T *eap) static void ex_buffer(exarg_T *eap)
{ {
if (*eap->arg) { if (*eap->arg) {
eap->errmsg = e_trailing; eap->errmsg = ex_errmsg(e_trailing_arg, eap->arg);
} else { } else {
if (eap->addr_count == 0) { // default is current buffer if (eap->addr_count == 0) { // default is current buffer
goto_buffer(eap, DOBUF_CURRENT, FORWARD, 0); goto_buffer(eap, DOBUF_CURRENT, FORWARD, 0);
@ -5943,7 +5943,7 @@ static void ex_recover(exarg_T *eap)
/// Command modifier used in a wrong way. /// Command modifier used in a wrong way.
static void ex_wrongmodifier(exarg_T *eap) static void ex_wrongmodifier(exarg_T *eap)
{ {
eap->errmsg = e_invcmd; eap->errmsg = _(e_invcmd);
} }
/// :sview [+command] file split window with new file, read-only /// :sview [+command] file split window with new file, read-only
@ -6052,7 +6052,7 @@ static void ex_tabnext(exarg_T *eap)
if (p == p_save || *p_save == '-' || *p_save == '+' || *p != NUL if (p == p_save || *p_save == '-' || *p_save == '+' || *p != NUL
|| tab_number == 0) { || tab_number == 0) {
// No numbers as argument. // No numbers as argument.
eap->errmsg = e_invarg; eap->errmsg = ex_errmsg(e_invarg2, eap->arg);
return; return;
} }
} else { } else {
@ -6061,7 +6061,7 @@ static void ex_tabnext(exarg_T *eap)
} else { } else {
tab_number = (int)eap->line2; tab_number = (int)eap->line2;
if (tab_number < 1) { if (tab_number < 1) {
eap->errmsg = e_invrange; eap->errmsg = _(e_invrange);
return; return;
} }
} }
@ -6339,7 +6339,7 @@ void do_exedit(exarg_T *eap, win_T *old_curwin)
/// ":gui" and ":gvim" when there is no GUI. /// ":gui" and ":gvim" when there is no GUI.
static void ex_nogui(exarg_T *eap) static void ex_nogui(exarg_T *eap)
{ {
eap->errmsg = N_("E25: Nvim does not have a built-in GUI"); eap->errmsg = _("E25: Nvim does not have a built-in GUI");
} }
static void ex_popup(exarg_T *eap) static void ex_popup(exarg_T *eap)
@ -7274,7 +7274,7 @@ static void ex_mark(exarg_T *eap)
if (*eap->arg == NUL) { // No argument? if (*eap->arg == NUL) { // No argument?
emsg(_(e_argreq)); emsg(_(e_argreq));
} else if (eap->arg[1] != NUL) { // more than one character? } else if (eap->arg[1] != NUL) { // more than one character?
emsg(_(e_trailing)); semsg(_(e_trailing_arg), eap->arg);
} else { } else {
pos = curwin->w_cursor; // save curwin->w_cursor pos = curwin->w_cursor; // save curwin->w_cursor
curwin->w_cursor.lnum = eap->line2; curwin->w_cursor.lnum = eap->line2;
@ -7559,7 +7559,7 @@ static void ex_findpat(exarg_T *eap)
// Check for trailing illegal characters. // Check for trailing illegal characters.
if (!ends_excmd(*p)) { if (!ends_excmd(*p)) {
eap->errmsg = e_trailing; eap->errmsg = ex_errmsg(e_trailing_arg, p);
} else { } else {
eap->nextcmd = (char *)check_nextcmd((char_u *)p); eap->nextcmd = (char *)check_nextcmd((char_u *)p);
} }

View File

@ -812,7 +812,7 @@ void ex_if(exarg_T *eap)
cstack_T *const cstack = eap->cstack; cstack_T *const cstack = eap->cstack;
if (cstack->cs_idx == CSTACK_LEN - 1) { if (cstack->cs_idx == CSTACK_LEN - 1) {
eap->errmsg = N_("E579: :if nesting too deep"); eap->errmsg = _("E579: :if nesting too deep");
} else { } else {
++cstack->cs_idx; ++cstack->cs_idx;
cstack->cs_flags[cstack->cs_idx] = 0; cstack->cs_flags[cstack->cs_idx] = 0;
@ -840,7 +840,7 @@ void ex_endif(exarg_T *eap)
if (eap->cstack->cs_idx < 0 if (eap->cstack->cs_idx < 0
|| (eap->cstack->cs_flags[eap->cstack->cs_idx] || (eap->cstack->cs_flags[eap->cstack->cs_idx]
& (CSF_WHILE | CSF_FOR | CSF_TRY))) { & (CSF_WHILE | CSF_FOR | CSF_TRY))) {
eap->errmsg = N_("E580: :endif without :if"); eap->errmsg = _("E580: :endif without :if");
} else { } else {
// When debugging or a breakpoint was encountered, display the debug // When debugging or a breakpoint was encountered, display the debug
// prompt (if not already done). This shows the user that an ":endif" // prompt (if not already done). This shows the user that an ":endif"
@ -870,17 +870,17 @@ void ex_else(exarg_T *eap)
|| (cstack->cs_flags[cstack->cs_idx] || (cstack->cs_flags[cstack->cs_idx]
& (CSF_WHILE | CSF_FOR | CSF_TRY))) { & (CSF_WHILE | CSF_FOR | CSF_TRY))) {
if (eap->cmdidx == CMD_else) { if (eap->cmdidx == CMD_else) {
eap->errmsg = N_("E581: :else without :if"); eap->errmsg = _("E581: :else without :if");
return; return;
} }
eap->errmsg = N_("E582: :elseif without :if"); eap->errmsg = _("E582: :elseif without :if");
skip = true; skip = true;
} else if (cstack->cs_flags[cstack->cs_idx] & CSF_ELSE) { } else if (cstack->cs_flags[cstack->cs_idx] & CSF_ELSE) {
if (eap->cmdidx == CMD_else) { if (eap->cmdidx == CMD_else) {
eap->errmsg = N_("E583: multiple :else"); eap->errmsg = _("E583: multiple :else");
return; return;
} }
eap->errmsg = N_("E584: :elseif after :else"); eap->errmsg = _("E584: :elseif after :else");
skip = true; skip = true;
} }
@ -940,7 +940,7 @@ void ex_while(exarg_T *eap)
cstack_T *const cstack = eap->cstack; cstack_T *const cstack = eap->cstack;
if (cstack->cs_idx == CSTACK_LEN - 1) { if (cstack->cs_idx == CSTACK_LEN - 1) {
eap->errmsg = N_("E585: :while/:for nesting too deep"); eap->errmsg = _("E585: :while/:for nesting too deep");
} else { } else {
/* /*
* The loop flag is set when we have jumped back from the matching * The loop flag is set when we have jumped back from the matching
@ -1019,7 +1019,7 @@ void ex_continue(exarg_T *eap)
cstack_T *const cstack = eap->cstack; cstack_T *const cstack = eap->cstack;
if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) { if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) {
eap->errmsg = N_("E586: :continue without :while or :for"); eap->errmsg = _("E586: :continue without :while or :for");
} else { } else {
// Try to find the matching ":while". This might stop at a try // Try to find the matching ":while". This might stop at a try
// conditional not in its finally clause (which is then to be executed // conditional not in its finally clause (which is then to be executed
@ -1051,7 +1051,7 @@ void ex_break(exarg_T *eap)
cstack_T *const cstack = eap->cstack; cstack_T *const cstack = eap->cstack;
if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) { if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) {
eap->errmsg = N_("E587: :break without :while or :for"); eap->errmsg = _("E587: :break without :while or :for");
} else { } else {
// Deactivate conditionals until the matching ":while" or a try // Deactivate conditionals until the matching ":while" or a try
// conditional not in its finally clause (which is then to be // conditional not in its finally clause (which is then to be
@ -1083,7 +1083,7 @@ void ex_endwhile(exarg_T *eap)
} }
if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) { if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) {
eap->errmsg = err; eap->errmsg = _(err);
} else { } else {
fl = cstack->cs_flags[cstack->cs_idx]; fl = cstack->cs_flags[cstack->cs_idx];
if (!(fl & csf)) { if (!(fl & csf)) {
@ -1097,9 +1097,9 @@ void ex_endwhile(exarg_T *eap)
} }
if (!(fl & (CSF_WHILE | CSF_FOR))) { if (!(fl & (CSF_WHILE | CSF_FOR))) {
if (!(fl & CSF_TRY)) { if (!(fl & CSF_TRY)) {
eap->errmsg = e_endif; eap->errmsg = _(e_endif);
} else if (fl & CSF_FINALLY) { } else if (fl & CSF_FINALLY) {
eap->errmsg = e_endtry; eap->errmsg = _(e_endtry);
} }
// Try to find the matching ":while" and report what's missing. // Try to find the matching ":while" and report what's missing.
for (idx = cstack->cs_idx; idx > 0; --idx) { for (idx = cstack->cs_idx; idx > 0; --idx) {
@ -1107,7 +1107,7 @@ void ex_endwhile(exarg_T *eap)
if ((fl & CSF_TRY) && !(fl & CSF_FINALLY)) { if ((fl & CSF_TRY) && !(fl & CSF_FINALLY)) {
// Give up at a try conditional not in its finally clause. // Give up at a try conditional not in its finally clause.
// Ignore the ":endwhile"/":endfor". // Ignore the ":endwhile"/":endfor".
eap->errmsg = err; eap->errmsg = _(err);
return; return;
} }
if (fl & csf) { if (fl & csf) {
@ -1230,7 +1230,7 @@ void ex_try(exarg_T *eap)
cstack_T *const cstack = eap->cstack; cstack_T *const cstack = eap->cstack;
if (cstack->cs_idx == CSTACK_LEN - 1) { if (cstack->cs_idx == CSTACK_LEN - 1) {
eap->errmsg = N_("E601: :try nesting too deep"); eap->errmsg = _("E601: :try nesting too deep");
} else { } else {
++cstack->cs_idx; ++cstack->cs_idx;
++cstack->cs_trylevel; ++cstack->cs_trylevel;
@ -1289,7 +1289,7 @@ void ex_catch(exarg_T *eap)
char *pat; char *pat;
if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) { if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) {
eap->errmsg = N_("E603: :catch without :try"); eap->errmsg = _("E603: :catch without :try");
give_up = true; give_up = true;
} else { } else {
if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) { if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) {
@ -1306,7 +1306,7 @@ void ex_catch(exarg_T *eap)
if (cstack->cs_flags[idx] & CSF_FINALLY) { if (cstack->cs_flags[idx] & CSF_FINALLY) {
// Give up for a ":catch" after ":finally" and ignore it. // Give up for a ":catch" after ":finally" and ignore it.
// Just parse. // Just parse.
eap->errmsg = N_("E604: :catch after :finally"); eap->errmsg = _("E604: :catch after :finally");
give_up = true; give_up = true;
} else { } else {
rewind_conditionals(cstack, idx, CSF_WHILE | CSF_FOR, rewind_conditionals(cstack, idx, CSF_WHILE | CSF_FOR,
@ -1341,7 +1341,7 @@ void ex_catch(exarg_T *eap)
if (!skip && (cstack->cs_flags[idx] & CSF_THROWN) if (!skip && (cstack->cs_flags[idx] & CSF_THROWN)
&& !(cstack->cs_flags[idx] & CSF_CAUGHT)) { && !(cstack->cs_flags[idx] & CSF_CAUGHT)) {
if (end != NULL && *end != NUL && !ends_excmd(*skipwhite(end + 1))) { if (end != NULL && *end != NUL && !ends_excmd(*skipwhite(end + 1))) {
emsg(_(e_trailing)); semsg(_(e_trailing_arg), end);
return; return;
} }
@ -1436,7 +1436,7 @@ void ex_finally(exarg_T *eap)
cstack_T *const cstack = eap->cstack; cstack_T *const cstack = eap->cstack;
if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) { if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) {
eap->errmsg = N_("E606: :finally without :try"); eap->errmsg = _("E606: :finally without :try");
} else { } else {
if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) { if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) {
eap->errmsg = get_end_emsg(cstack); eap->errmsg = get_end_emsg(cstack);
@ -1455,7 +1455,7 @@ void ex_finally(exarg_T *eap)
if (cstack->cs_flags[idx] & CSF_FINALLY) { if (cstack->cs_flags[idx] & CSF_FINALLY) {
// Give up for a multiple ":finally" and ignore it. // Give up for a multiple ":finally" and ignore it.
eap->errmsg = N_("E607: multiple :finally"); eap->errmsg = _("E607: multiple :finally");
return; return;
} }
rewind_conditionals(cstack, idx, CSF_WHILE | CSF_FOR, rewind_conditionals(cstack, idx, CSF_WHILE | CSF_FOR,
@ -1559,7 +1559,7 @@ void ex_endtry(exarg_T *eap)
cstack_T *const cstack = eap->cstack; cstack_T *const cstack = eap->cstack;
if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) { if (cstack->cs_trylevel <= 0 || cstack->cs_idx < 0) {
eap->errmsg = N_("E602: :endtry without :try"); eap->errmsg = _("E602: :endtry without :try");
} else { } else {
// Don't do something after an error, interrupt or throw in the try // Don't do something after an error, interrupt or throw in the try
// block, catch clause, or finally clause preceding this ":endtry" or // block, catch clause, or finally clause preceding this ":endtry" or
@ -1998,12 +1998,12 @@ int cleanup_conditionals(cstack_T *cstack, int searched_cond, int inclusive)
static char *get_end_emsg(cstack_T *cstack) static char *get_end_emsg(cstack_T *cstack)
{ {
if (cstack->cs_flags[cstack->cs_idx] & CSF_WHILE) { if (cstack->cs_flags[cstack->cs_idx] & CSF_WHILE) {
return e_endwhile; return _(e_endwhile);
} }
if (cstack->cs_flags[cstack->cs_idx] & CSF_FOR) { if (cstack->cs_flags[cstack->cs_idx] & CSF_FOR) {
return e_endfor; return _(e_endfor);
} }
return e_endif; return _(e_endif);
} }
/// Rewind conditionals until index "idx" is reached. "cond_type" and /// Rewind conditionals until index "idx" is reached. "cond_type" and

View File

@ -6525,7 +6525,7 @@ void ex_history(exarg_T *eap)
histype1 = 0; histype1 = 0;
histype2 = HIST_COUNT - 1; histype2 = HIST_COUNT - 1;
} else { } else {
emsg(_(e_trailing)); semsg(_(e_trailing_arg), arg);
return; return;
} }
} else { } else {
@ -6535,7 +6535,7 @@ void ex_history(exarg_T *eap)
end = arg; end = arg;
} }
if (!get_list_range(&end, &hisidx1, &hisidx2) || *end != NUL) { if (!get_list_range(&end, &hisidx1, &hisidx2) || *end != NUL) {
emsg(_(e_trailing)); semsg(_(e_trailing_arg), end);
return; return;
} }

View File

@ -973,7 +973,7 @@ EXTERN char e_longname[] INIT(= N_("E75: Name too long"));
EXTERN char e_toomsbra[] INIT(= N_("E76: Too many [")); EXTERN char e_toomsbra[] INIT(= N_("E76: Too many ["));
EXTERN char e_toomany[] INIT(= N_("E77: Too many file names")); EXTERN char e_toomany[] INIT(= N_("E77: Too many file names"));
EXTERN char e_trailing[] INIT(= N_("E488: Trailing characters")); EXTERN char e_trailing[] INIT(= N_("E488: Trailing characters"));
EXTERN char e_trailing2[] INIT(= N_("E488: Trailing characters: %s")); EXTERN char e_trailing_arg[] INIT(= N_("E488: Trailing characters: %s"));
EXTERN char e_umark[] INIT(= N_("E78: Unknown mark")); EXTERN char e_umark[] INIT(= N_("E78: Unknown mark"));
EXTERN char e_wildexpand[] INIT(= N_("E79: Cannot expand wildcards")); EXTERN char e_wildexpand[] INIT(= N_("E79: Cannot expand wildcards"));
EXTERN char e_winheight[] INIT(= N_("E591: 'winheight' cannot be smaller than 'winminheight'")); EXTERN char e_winheight[] INIT(= N_("E591: 'winheight' cannot be smaller than 'winminheight'"));

View File

@ -1193,7 +1193,7 @@ void ex_match(exarg_T *eap)
if (!eap->skip) { if (!eap->skip) {
if (*end != NUL && !ends_excmd(*skipwhite((char *)end + 1))) { if (*end != NUL && !ends_excmd(*skipwhite((char *)end + 1))) {
xfree(g); xfree(g);
eap->errmsg = e_trailing; eap->errmsg = ex_errmsg(e_trailing_arg, (const char *)end);
return; return;
} }
if (*end != *p) { if (*end != *p) {

View File

@ -175,7 +175,7 @@ void ex_menu(exarg_T *eap)
show_menus(menu_path, modes); show_menus(menu_path, modes);
goto theend; goto theend;
} else if (*map_to != NUL && (unmenu || enable != kNone)) { } else if (*map_to != NUL && (unmenu || enable != kNone)) {
emsg(_(e_trailing)); semsg(_(e_trailing_arg), map_to);
goto theend; goto theend;
} }

View File

@ -3120,7 +3120,7 @@ void qf_list(exarg_T *eap)
int idx1 = 1; int idx1 = 1;
int idx2 = -1; int idx2 = -1;
if (!get_list_range((char_u **)&arg, &idx1, &idx2) || *arg != NUL) { if (!get_list_range((char_u **)&arg, &idx1, &idx2) || *arg != NUL) {
emsg(_(e_trailing)); semsg(_(e_trailing_arg), arg);
return; return;
} }
qf_list_T *qfl = qf_get_curlist(qi); qf_list_T *qfl = qf_get_curlist(qi);

View File

@ -1395,7 +1395,7 @@ static int parse_sign_cmd_args(int cmd, char_u *arg, char_u **sign_name, int *si
filename = arg; filename = arg;
*buf = buflist_findnr(getdigits_int((char **)&arg, true, 0)); *buf = buflist_findnr(getdigits_int((char **)&arg, true, 0));
if (*skipwhite((char *)arg) != NUL) { if (*skipwhite((char *)arg) != NUL) {
emsg(_(e_trailing)); semsg(_(e_trailing_arg), arg);
} }
break; break;
} else { } else {

View File

@ -133,18 +133,18 @@ function Test_tabpage()
call assert_fails("99tabmove", 'E16:') call assert_fails("99tabmove", 'E16:')
call assert_fails("+99tabmove", 'E16:') call assert_fails("+99tabmove", 'E16:')
call assert_fails("-99tabmove", 'E16:') call assert_fails("-99tabmove", 'E16:')
call assert_fails("tabmove foo", 'E474:') call assert_fails("tabmove foo", 'E475:')
call assert_fails("tabmove 99", 'E474:') call assert_fails("tabmove 99", 'E475:')
call assert_fails("tabmove +99", 'E474:') call assert_fails("tabmove +99", 'E475:')
call assert_fails("tabmove -99", 'E474:') call assert_fails("tabmove -99", 'E475:')
call assert_fails("tabmove -3+", 'E474:') call assert_fails("tabmove -3+", 'E475:')
call assert_fails("tabmove $3", 'E474:') call assert_fails("tabmove $3", 'E475:')
call assert_fails("%tabonly", 'E16:') call assert_fails("%tabonly", 'E16:')
1tabonly! 1tabonly!
tabmove 1 tabmove 1
call assert_equal(1, tabpagenr()) call assert_equal(1, tabpagenr())
tabnew tabnew
call assert_fails("-2tabmove", 'E474:') call assert_fails("-2tabmove", 'E16:')
tabonly! tabonly!
endfunc endfunc
@ -320,14 +320,14 @@ function Test_tabpage_with_tabnext()
call Check_tab_count(4, 'tabnext -', 3) call Check_tab_count(4, 'tabnext -', 3)
call Check_tab_count(4, 'tabnext -2', 2) call Check_tab_count(4, 'tabnext -2', 2)
call Check_tab_count(3, 'tabnext $', 5) call Check_tab_count(3, 'tabnext $', 5)
call assert_fails('tabnext 0', 'E474:') call assert_fails('tabnext 0', 'E475:')
call assert_fails('tabnext .', 'E474:') call assert_fails('tabnext .', 'E475:')
call assert_fails('tabnext -+', 'E474:') call assert_fails('tabnext -+', 'E475:')
call assert_fails('tabnext +2-', 'E474:') call assert_fails('tabnext +2-', 'E475:')
call assert_fails('tabnext $3', 'E474:') call assert_fails('tabnext $3', 'E475:')
call assert_fails('tabnext 99', 'E474:') call assert_fails('tabnext 99', 'E475:')
call assert_fails('tabnext +99', 'E474:') call assert_fails('tabnext +99', 'E475:')
call assert_fails('tabnext -99', 'E474:') call assert_fails('tabnext -99', 'E475:')
1tabonly! 1tabonly!
endfunction endfunction
@ -352,7 +352,7 @@ function Test_tabpage_with_tabprevious()
let err_code = 'E16:' let err_code = 'E16:'
else else
let entire_cmd = cmd . ' ' . c let entire_cmd = cmd . ' ' . c
let err_code = 'E474:' let err_code = 'E475:'
endif endif
call assert_fails(entire_cmd, err_code) call assert_fails(entire_cmd, err_code)
endfor endfor
@ -451,7 +451,7 @@ function Test_tabpage_with_tabclose()
let err_code = 'E16:' let err_code = 'E16:'
else else
let entire_cmd = 'tabclose ' . c let entire_cmd = 'tabclose ' . c
let err_code = 'E474:' let err_code = 'E475:'
endif endif
call assert_fails(entire_cmd, err_code) call assert_fails(entire_cmd, err_code)
call assert_equal(6, tabpagenr('$')) call assert_equal(6, tabpagenr('$'))
@ -460,8 +460,8 @@ function Test_tabpage_with_tabclose()
call assert_fails('3tabclose', 'E37:') call assert_fails('3tabclose', 'E37:')
call assert_fails('tabclose 3', 'E37:') call assert_fails('tabclose 3', 'E37:')
call assert_fails('tabclose -+', 'E474:') call assert_fails('tabclose -+', 'E475:')
call assert_fails('tabclose +2-', 'E474:') call assert_fails('tabclose +2-', 'E475:')
call assert_equal(6, tabpagenr('$')) call assert_equal(6, tabpagenr('$'))
1tabonly! 1tabonly!
@ -506,7 +506,7 @@ function Test_tabpage_with_tabonly()
let err_code = 'E16:' let err_code = 'E16:'
else else
let entire_cmd = 'tabonly ' . c let entire_cmd = 'tabonly ' . c
let err_code = 'E474:' let err_code = 'E475:'
endif endif
call assert_fails(entire_cmd, err_code) call assert_fails(entire_cmd, err_code)
call assert_equal(6, tabpagenr('$')) call assert_equal(6, tabpagenr('$'))
@ -517,13 +517,13 @@ function Test_tabpage_with_tabonly()
for c in tc for c in tc
call s:reconstruct_tabpage_for_test(6) call s:reconstruct_tabpage_for_test(6)
let entire_cmd = 'tabonly' . c[2] . ' ' . c[1] let entire_cmd = 'tabonly' . c[2] . ' ' . c[1]
let err_code = 'E474:' let err_code = 'E475:'
call assert_fails(entire_cmd, err_code) call assert_fails(entire_cmd, err_code)
call assert_equal(6, tabpagenr('$')) call assert_equal(6, tabpagenr('$'))
endfor endfor
call assert_fails('tabonly -+', 'E474:') call assert_fails('tabonly -+', 'E475:')
call assert_fails('tabonly +2-', 'E474:') call assert_fails('tabonly +2-', 'E475:')
call assert_equal(6, tabpagenr('$')) call assert_equal(6, tabpagenr('$'))
1tabonly! 1tabonly!

View File

@ -87,14 +87,14 @@ describe(':cquit', function()
end) end)
it('exits with redir msg for multiple exit codes after :cquit 1 2', function() it('exits with redir msg for multiple exit codes after :cquit 1 2', function()
test_cq('cquit 1 2', nil, 'Vim(cquit):E488: Trailing characters: cquit 1 2') test_cq('cquit 1 2', nil, 'Vim(cquit):E488: Trailing characters: 2: cquit 1 2')
end) end)
it('exits with redir msg for non-number exit code after :cquit X', function() it('exits with redir msg for non-number exit code after :cquit X', function()
test_cq('cquit X', nil, 'Vim(cquit):E488: Trailing characters: cquit X') test_cq('cquit X', nil, 'Vim(cquit):E488: Trailing characters: X: cquit X')
end) end)
it('exits with redir msg for negative exit code after :cquit -1', function() it('exits with redir msg for negative exit code after :cquit -1', function()
test_cq('cquit -1', nil, 'Vim(cquit):E488: Trailing characters: cquit -1') test_cq('cquit -1', nil, 'Vim(cquit):E488: Trailing characters: -1: cquit -1')
end) end)
end) end)

View File

@ -16,7 +16,7 @@ describe('Ex cmds', function()
command(':echo expand("#<9999999999999999999999999999999999999999")') command(':echo expand("#<9999999999999999999999999999999999999999")')
command(':lockvar 9999999999999999999999999999999999999999') command(':lockvar 9999999999999999999999999999999999999999')
command(':winsize 9999999999999999999999999999999999999999 9999999999999999999999999999999999999999') command(':winsize 9999999999999999999999999999999999999999 9999999999999999999999999999999999999999')
eq('Vim(tabnext):E474: Invalid argument', eq('Vim(tabnext):E475: Invalid argument: 9999999999999999999999999999999999999999',
pcall_err(command, ':tabnext 9999999999999999999999999999999999999999')) pcall_err(command, ':tabnext 9999999999999999999999999999999999999999'))
eq('Vim(Next):E939: Positive count required', eq('Vim(Next):E939: Positive count required',
pcall_err(command, ':N 9999999999999999999999999999999999999999')) pcall_err(command, ':N 9999999999999999999999999999999999999999'))

View File

@ -1,239 +0,0 @@
-- Tests for tab pages
local helpers = require('test.functional.helpers')(after_each)
local feed, insert, source, clear, command, expect, eval, eq =
helpers.feed, helpers.insert, helpers.source, helpers.clear,
helpers.command, helpers.expect, helpers.eval, helpers.eq
local exc_exec = helpers.exc_exec
describe('tab pages', function()
before_each(clear)
it('can be opened and closed', function()
command('tabnew')
eq(2, eval('tabpagenr()'))
command('quit')
eq(1, eval('tabpagenr()'))
end)
it('can be iterated with :tabdo', function()
source([[
0tabnew
1tabnew
$tabnew
tabdo call append(line('$'), 'this is tab page ' . tabpagenr())
tabclose! 2
tabrewind
]])
eq('this is tab page 1', eval("getline('$')"))
command('tablast')
eq('this is tab page 4', eval("getline('$')"))
end)
it('have local variables accasible with settabvar()/gettabvar()', function()
-- Test for settabvar() and gettabvar() functions. Open a new tab page and
-- set 3 variables to a number, string and a list. Verify that the
-- variables are correctly set.
source([[
tabnew
tabfirst
call settabvar(2, 'val_num', 100)
call settabvar(2, 'val_str', 'SetTabVar test')
call settabvar(2, 'val_list', ['red', 'blue', 'green'])
]])
eq(100, eval('gettabvar(2, "val_num")'))
eq('SetTabVar test', eval('gettabvar(2, "val_str")'))
eq({'red', 'blue', 'green'}, eval('gettabvar(2, "val_list")'))
command('tabnext 2')
eq(100, eval('t:val_num'))
eq('SetTabVar test', eval('t:val_str'))
eq({'red', 'blue', 'green'}, eval('t:val_list'))
end)
it('work together with the drop feature and loaded buffers', function()
-- Test for ":tab drop exist-file" to keep current window.
command('sp test1')
command('tab drop test1')
eq(1, eval('tabpagenr("$")'))
eq(2, eval('winnr("$")'))
eq(1, eval('winnr()'))
end)
it('work together with the drop feature and new files', function()
-- Test for ":tab drop new-file" to keep current window of tabpage 1.
command('split')
command('tab drop newfile')
eq(2, eval('tabpagenr("$")'))
eq(2, eval('tabpagewinnr(1, "$")'))
eq(1, eval('tabpagewinnr(1)'))
end)
it('work together with the drop feature and multi loaded buffers', function()
-- Test for ":tab drop multi-opend-file" to keep current tabpage and
-- window.
command('new test1')
command('tabnew')
command('new test1')
command('tab drop test1')
eq(2, eval('tabpagenr()'))
eq(2, eval('tabpagewinnr(2, "$")'))
eq(1, eval('tabpagewinnr(2)'))
end)
it('can be navigated with :tabmove', function()
command('lang C')
command('for i in range(9) | tabnew | endfor')
feed('1gt')
eq(1, eval('tabpagenr()'))
command('tabmove 5')
eq(5, eval('tabpagenr()'))
command('.tabmove')
eq(5, eval('tabpagenr()'))
command('tabmove -')
eq(4, eval('tabpagenr()'))
command('tabmove +')
eq(5, eval('tabpagenr()'))
command('tabmove -2')
eq(3, eval('tabpagenr()'))
command('tabmove +4')
eq(7, eval('tabpagenr()'))
command('tabmove')
eq(10, eval('tabpagenr()'))
command('0tabmove')
eq(1, eval('tabpagenr()'))
command('$tabmove')
eq(10, eval('tabpagenr()'))
command('tabmove 0')
eq(1, eval('tabpagenr()'))
command('tabmove $')
eq(10, eval('tabpagenr()'))
command('3tabmove')
eq(4, eval('tabpagenr()'))
command('7tabmove 5')
eq(5, eval('tabpagenr()'))
command('let a="No error caught."')
eq('Vim(tabmove):E474: Invalid argument: tabmove foo',
exc_exec('tabmove foo'))
end)
it('can trigger certain autocommands', function()
insert('Results:')
-- Test autocommands.
source([[
tabonly!
let g:r=[]
command -nargs=1 -bar C :call add(g:r, '=== '.<q-args>.' ===')|<args>
function Test()
autocmd TabEnter * :call add(g:r, 'TabEnter')
autocmd WinEnter * :call add(g:r, 'WinEnter')
autocmd BufEnter * :call add(g:r, 'BufEnter')
autocmd TabLeave * :call add(g:r, 'TabLeave')
autocmd WinLeave * :call add(g:r, 'WinLeave')
autocmd BufLeave * :call add(g:r, 'BufLeave')
let t:a='a'
C tab split
let t:a='b'
C tabnew
let t:a='c'
call add(g:r, join(map(range(1, tabpagenr('$')),
\ 'gettabvar(v:val, "a")')))
C call map(range(1, tabpagenr('$')),
\ 'settabvar(v:val, ''a'', v:val*2)')
call add(g:r, join(map(range(1, tabpagenr('$')),
\ 'gettabvar(v:val, "a")')))
let w:a='a'
C vsplit
let w:a='a'
let tabn=tabpagenr()
let winr=range(1, winnr('$'))
C tabnext 1
call add(g:r, join(map(copy(winr),
\ 'gettabwinvar('.tabn.', v:val, "a")')))
C call map(copy(winr),
\ 'settabwinvar('.tabn.', v:val, ''a'', v:val*2)')
call add(g:r, join(map(copy(winr),
\ 'gettabwinvar('.tabn.', v:val, "a")')))
augroup TabDestructive
autocmd TabEnter * :C tabnext 2 | C tabclose 3
augroup END
C tabnext 3
let g:r+=[tabpagenr().'/'.tabpagenr('$')]
autocmd! TabDestructive TabEnter
C tabnew
C tabnext 1
autocmd TabDestructive TabEnter * nested
\ :C tabnext 2 | C tabclose 3
C tabnext 2
let g:r+=[tabpagenr().'/'.tabpagenr('$')]
endfunction
call Test()
$ put =g:r
]])
-- Assert buffer contents.
expect([[
Results:
=== tab split ===
WinLeave
TabLeave
WinEnter
TabEnter
=== tabnew ===
WinLeave
TabLeave
WinEnter
TabEnter
BufLeave
BufEnter
a b c
=== call map(range(1, tabpagenr('$')), 'settabvar(v:val, ''a'', v:val*2)') ===
2 4 6
=== vsplit ===
WinLeave
WinEnter
=== tabnext 1 ===
BufLeave
WinLeave
TabLeave
WinEnter
TabEnter
BufEnter
a a
=== call map(copy(winr), 'settabwinvar('.tabn.', v:val, ''a'', v:val*2)') ===
2 4
=== tabnext 3 ===
BufLeave
WinLeave
TabLeave
WinEnter
TabEnter
=== tabnext 2 ===
=== tabclose 3 ===
2/2
=== tabnew ===
WinLeave
TabLeave
WinEnter
TabEnter
BufLeave
BufEnter
=== tabnext 1 ===
BufLeave
WinLeave
TabLeave
WinEnter
TabEnter
BufEnter
=== tabnext 2 ===
WinLeave
TabLeave
WinEnter
TabEnter
=== tabnext 2 ===
=== tabclose 3 ===
2/2]])
eq(2, eval("tabpagenr('$')"))
end)
end)