diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-05-10 19:18:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-10 19:18:58 +0200 |
commit | 8d40b3617c8bb10af5d4d4abcab0dfe77a4e807d (patch) | |
tree | cded38835bde85bc8a1682303617f84bf2549f7e /src/nvim/eval.c | |
parent | 1cd8517344c0d99ca6fb3246c70f78d271993cf6 (diff) | |
parent | 966e7abc4960746b4dde618807fb5516d162ae2d (diff) | |
download | rneovim-8d40b3617c8bb10af5d4d4abcab0dfe77a4e807d.tar.gz rneovim-8d40b3617c8bb10af5d4d4abcab0dfe77a4e807d.tar.bz2 rneovim-8d40b3617c8bb10af5d4d4abcab0dfe77a4e807d.zip |
Merge #8371 'API: more reliable/descriptive VimL errors'
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index cc29496968..45a1776c86 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6241,20 +6241,21 @@ bool set_ref_in_func(char_u *name, ufunc_T *fp_in, int copyID) /// invoked function uses them. It is called like this: /// new_argcount = argv_func(current_argcount, argv, called_func_argcount) /// -/// Return FAIL when the function can't be called, OK otherwise. -/// Also returns OK when an error was encountered while executing the function. +/// @return FAIL if function cannot be called, else OK (even if an error +/// occurred while executing the function! Set `msg_list` to capture +/// the error, see do_cmdline()). int call_func( const char_u *funcname, // name of the function int len, // length of "name" - typval_T *rettv, // return value goes here + typval_T *rettv, // [out] value goes here int argcount_in, // number of "argvars" typval_T *argvars_in, // vars for arguments, must have "argcount" // PLUS ONE elements! ArgvFunc argv_func, // function to fill in argvars linenr_T firstline, // first line of range linenr_T lastline, // last line of range - int *doesrange, // return: function handled range + int *doesrange, // [out] function handled range bool evaluate, partial_T *partial, // optional, can be NULL dict_T *selfdict_in // Dictionary for "self" @@ -6428,21 +6429,25 @@ call_func( return ret; } -/* - * Give an error message with a function name. Handle <SNR> things. - * "ermsg" is to be passed without translation, use N_() instead of _(). - */ +/// Give an error message with a function name. Handle <SNR> things. +/// +/// @param ermsg must be passed without translation (use N_() instead of _()). +/// @param name function name static void emsg_funcname(char *ermsg, char_u *name) { - char_u *p; + char_u *p; - if (*name == K_SPECIAL) + if (*name == K_SPECIAL) { p = concat_str((char_u *)"<SNR>", name + 3); - else + } else { p = name; + } + EMSG2(_(ermsg), p); - if (p != name) + + if (p != name) { xfree(p); + } } /* |