diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-08-07 14:09:32 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-08-07 14:39:19 +0800 |
commit | 48051ed62cde6ab572bcd48768fe43740f3cd48c (patch) | |
tree | b016aaf3d9c8cd62d701ebe8f0dbaf17f645bc3a | |
parent | d0686540f56154e269e11eb0cc6cd3eb759f2b77 (diff) | |
download | rneovim-48051ed62cde6ab572bcd48768fe43740f3cd48c.tar.gz rneovim-48051ed62cde6ab572bcd48768fe43740f3cd48c.tar.bz2 rneovim-48051ed62cde6ab572bcd48768fe43740f3cd48c.zip |
vim-patch:8.2.1281: the "trailing characters" error can be hard to understand
Problem: The "trailing characters" error can be hard to understand.
Solution: Add the trailing characters to the message.
https://github.com/vim/vim/commit/2d06bfde29bd3a62fc85823d2aa719ef943bd319
-rw-r--r-- | src/nvim/eval.c | 6 | ||||
-rw-r--r-- | src/nvim/eval/funcs.c | 4 | ||||
-rw-r--r-- | src/nvim/eval/userfunc.c | 8 | ||||
-rw-r--r-- | src/nvim/eval/vars.c | 6 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 2 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 4 | ||||
-rw-r--r-- | src/nvim/ex_eval.c | 2 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 4 | ||||
-rw-r--r-- | src/nvim/menu.c | 2 | ||||
-rw-r--r-- | src/nvim/quickfix.c | 2 | ||||
-rw-r--r-- | src/nvim/sign.c | 2 | ||||
-rw-r--r-- | test/functional/core/exit_spec.lua | 6 |
12 files changed, 24 insertions, 24 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index fc627ae5db..5911a93099 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -544,9 +544,9 @@ int var_redir_start(char *name, int append) clear_lval(redir_lval); if (redir_endp != NULL && *redir_endp != NUL) { // Trailing characters are present after the variable name - emsg(_(e_trailing)); + semsg(_(e_trailing_arg), redir_endp); } else { - emsg(_(e_invarg)); + semsg(_(e_invarg2), name); } redir_endp = NULL; // don't store a value, only cleanup 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. if (unlet && !ascii_iswhite(*p) && !ends_excmd(*p) && *p != '[' && *p != '.') { - emsg(_(e_trailing)); + semsg(_(e_trailing_arg), p); return NULL; } diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index d121c106d0..060dc50f52 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -1839,7 +1839,7 @@ static void f_eval(typval_T *argvars, typval_T *rettv, FunPtr fptr) rettv->v_type = VAR_NUMBER; rettv->vval.v_number = 0; } 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); if (end != NULL && lv.ll_name != NULL) { if (*end != NUL) { - emsg(_(e_trailing)); + semsg(_(e_trailing_arg), end); } else { if (lv.ll_tv == NULL) { di = find_var(lv.ll_name, lv.ll_name_len, NULL, true); diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index a90148bf23..2f4799db57 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -2039,7 +2039,7 @@ void ex_function(exarg_T *eap) // if (!paren) { if (!ends_excmd(*skipwhite((char *)p))) { - emsg(_(e_trailing)); + semsg(_(e_trailing_arg), p); goto ret_free; } eap->nextcmd = (char *)check_nextcmd(p); @@ -2163,7 +2163,7 @@ void ex_function(exarg_T *eap) if (*p == '\n') { line_arg = p + 1; } 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))) { xfree(name); - emsg(_(e_trailing)); + semsg(_(e_trailing_arg), p); return; } eap->nextcmd = (char *)check_nextcmd(p); @@ -3021,7 +3021,7 @@ void ex_call(exarg_T *eap) if (!ends_excmd(*arg)) { if (!failed && !aborting()) { emsg_severe = true; - emsg(_(e_trailing)); + semsg(_(e_trailing_arg), arg); } } else { eap->nextcmd = (char *)check_nextcmd(arg); diff --git a/src/nvim/eval/vars.c b/src/nvim/eval/vars.c index dec3ef68aa..033b6094b4 100644 --- a/src/nvim/eval/vars.c +++ b/src/nvim/eval/vars.c @@ -80,7 +80,7 @@ static list_T *heredoc_get(exarg_T *eap, char *cmd) marker = skipwhite(cmd); p = (char *)skiptowhite((char_u *)marker); if (*skipwhite(p) != NUL && *skipwhite(p) != '"') { - emsg(_(e_trailing)); + semsg(_(e_trailing_arg), p); return NULL; } *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); if (!ascii_iswhite(*arg) && !ends_excmd(*arg)) { emsg_severe = true; - emsg(_(e_trailing)); + semsg(_(e_trailing_arg), arg); break; } } 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))) { if (name_end != NULL) { emsg_severe = true; - emsg(_(e_trailing)); + semsg(_(e_trailing_arg), name_end); } if (!(eap->skip || error)) { clear_lval(&lv); diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 23e7660606..9d1ac185d4 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -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 eap->nextcmd = (char *)check_nextcmd((char_u *)cmd); if (eap->nextcmd == NULL) { - emsg(_(e_trailing)); + semsg(_(e_trailing_arg), cmd); return 0; } } diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 70d729963c..4ac9847e53 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -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 && *ea.arg != '"' && (*ea.arg != '|' || (ea.argt & EX_TRLBAR) == 0)) { // no arguments allowed but there is something - errormsg = _(e_trailing); + errormsg = ex_errmsg(e_trailing_arg, ea.arg); goto doend; } @@ -7274,7 +7274,7 @@ static void ex_mark(exarg_T *eap) if (*eap->arg == NUL) { // No argument? emsg(_(e_argreq)); } else if (eap->arg[1] != NUL) { // more than one character? - emsg(_(e_trailing)); + semsg(_(e_trailing_arg), eap->arg); } else { pos = curwin->w_cursor; // save curwin->w_cursor curwin->w_cursor.lnum = eap->line2; diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 186c1d6ef5..f67c8a6720 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -1341,7 +1341,7 @@ void ex_catch(exarg_T *eap) if (!skip && (cstack->cs_flags[idx] & CSF_THROWN) && !(cstack->cs_flags[idx] & CSF_CAUGHT)) { if (end != NULL && *end != NUL && !ends_excmd(*skipwhite(end + 1))) { - emsg(_(e_trailing)); + semsg(_(e_trailing_arg), end); return; } diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 6240ac6b37..07a0e68884 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -6525,7 +6525,7 @@ void ex_history(exarg_T *eap) histype1 = 0; histype2 = HIST_COUNT - 1; } else { - emsg(_(e_trailing)); + semsg(_(e_trailing_arg), arg); return; } } else { @@ -6535,7 +6535,7 @@ void ex_history(exarg_T *eap) end = arg; } if (!get_list_range(&end, &hisidx1, &hisidx2) || *end != NUL) { - emsg(_(e_trailing)); + semsg(_(e_trailing_arg), end); return; } diff --git a/src/nvim/menu.c b/src/nvim/menu.c index be13675b2a..16802a4e50 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -175,7 +175,7 @@ void ex_menu(exarg_T *eap) show_menus(menu_path, modes); goto theend; } else if (*map_to != NUL && (unmenu || enable != kNone)) { - emsg(_(e_trailing)); + semsg(_(e_trailing_arg), map_to); goto theend; } diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 9b46fad67a..99129bd15e 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -3120,7 +3120,7 @@ void qf_list(exarg_T *eap) int idx1 = 1; int idx2 = -1; if (!get_list_range((char_u **)&arg, &idx1, &idx2) || *arg != NUL) { - emsg(_(e_trailing)); + semsg(_(e_trailing_arg), arg); return; } qf_list_T *qfl = qf_get_curlist(qi); diff --git a/src/nvim/sign.c b/src/nvim/sign.c index 1640d0167e..7b6b55fede 100644 --- a/src/nvim/sign.c +++ b/src/nvim/sign.c @@ -1395,7 +1395,7 @@ static int parse_sign_cmd_args(int cmd, char_u *arg, char_u **sign_name, int *si filename = arg; *buf = buflist_findnr(getdigits_int((char **)&arg, true, 0)); if (*skipwhite((char *)arg) != NUL) { - emsg(_(e_trailing)); + semsg(_(e_trailing_arg), arg); } break; } else { diff --git a/test/functional/core/exit_spec.lua b/test/functional/core/exit_spec.lua index a47e7568a9..4dba58dbfc 100644 --- a/test/functional/core/exit_spec.lua +++ b/test/functional/core/exit_spec.lua @@ -87,14 +87,14 @@ describe(':cquit', function() end) 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) 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) 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) |