diff options
Diffstat (limited to 'src/nvim/eval')
-rw-r--r-- | src/nvim/eval/funcs.c | 39 | ||||
-rw-r--r-- | src/nvim/eval/userfunc.c | 15 |
2 files changed, 32 insertions, 22 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index f97ceedeb7..c6993d2ff8 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -15,8 +15,8 @@ #include "nvim/charset.h" #include "nvim/context.h" #include "nvim/cursor.h" -#include "nvim/digraph.h" #include "nvim/diff.h" +#include "nvim/digraph.h" #include "nvim/edit.h" #include "nvim/eval.h" #include "nvim/eval/decode.h" @@ -135,8 +135,7 @@ char_u *get_function_name(expand_T *xp, int idx) } } while ((size_t)++intidx < ARRAY_SIZE(functions) - && functions[intidx].name[0] == '\0') { - } + && functions[intidx].name[0] == '\0') {} if ((size_t)intidx >= ARRAY_SIZE(functions)) { return NULL; @@ -1019,7 +1018,7 @@ static void f_chdir(typval_T *argvars, typval_T *rettv, FunPtr fptr) scope = kCdScopeTabpage; } - if (!changedir_func(argvars[0].vval.v_string, scope)) { + if (!changedir_func((char *)argvars[0].vval.v_string, scope)) { // Directory change failed XFREE_CLEAR(rettv->vval.v_string); } @@ -2194,7 +2193,7 @@ static void f_expandcmd(typval_T *argvars, typval_T *rettv, FunPtr fptr) char_u *cmdstr = (char_u *)xstrdup(tv_get_string(&argvars[0])); exarg_T eap = { - .cmd = cmdstr, + .cmd = (char *)cmdstr, .arg = cmdstr, .usefilter = false, .nextcmd = NULL, @@ -2445,7 +2444,7 @@ static void f_float2nr(typval_T *argvars, typval_T *rettv, FunPtr fptr) float_T f; if (tv_get_float_chk(argvars, &f)) { - if (f <= (float_T)-VARNUMBER_MAX + DBL_EPSILON) { + if (f <= (float_T) - VARNUMBER_MAX + DBL_EPSILON) { rettv->vval.v_number = -VARNUMBER_MAX; } else if (f >= (float_T)VARNUMBER_MAX - DBL_EPSILON) { rettv->vval.v_number = VARNUMBER_MAX; @@ -2631,8 +2630,7 @@ static void f_foldtextresult(typval_T *argvars, typval_T *rettv, FunPtr fptr) /// "foreground()" function static void f_foreground(typval_T *argvars, typval_T *rettv, FunPtr fptr) -{ -} +{} static void f_funcref(typval_T *argvars, typval_T *rettv, FunPtr fptr) { @@ -2975,6 +2973,7 @@ static void getchar_common(typval_T *argvars, typval_T *rettv) bool error = false; no_mapping++; + allow_keys++; for (;;) { // Position the cursor. Needed after a message that ends in a space, // or if event processing caused a redraw. @@ -3012,6 +3011,7 @@ static void getchar_common(typval_T *argvars, typval_T *rettv) break; } no_mapping--; + allow_keys--; set_vim_var_nr(VV_MOUSE_WIN, 0); set_vim_var_nr(VV_MOUSE_WINID, 0); @@ -3855,8 +3855,7 @@ static void f_getwininfo(typval_T *argvars, typval_T *rettv, FunPtr fptr) /// Dummy timer callback. Used by f_wait(). static void dummy_timer_due_cb(TimeWatcher *tw, void *data) -{ -} +{} /// Dummy timer close callback. Used by f_wait(). static void dummy_timer_close_cb(TimeWatcher *tw, void *data) @@ -5648,6 +5647,8 @@ static void f_localtime(typval_T *argvars, typval_T *rettv, FunPtr fptr) static void get_maparg(typval_T *argvars, typval_T *rettv, int exact) { char_u *keys_buf = NULL; + char_u *alt_keys_buf = NULL; + bool did_simplify = false; char_u *rhs; LuaRef rhs_lua; int mode; @@ -5655,6 +5656,7 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact) int get_dict = FALSE; mapblock_T *mp; int buffer_local; + int flags = REPTERM_FROM_PART | REPTERM_DO_LT; // Return empty string for failure. rettv->v_type = VAR_STRING; @@ -5684,10 +5686,16 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact) mode = get_map_mode((char_u **)&which, 0); - keys = replace_termcodes(keys, STRLEN(keys), &keys_buf, true, true, true, - CPO_TO_CPO_FLAGS); - rhs = check_map(keys, mode, exact, false, abbr, &mp, &buffer_local, &rhs_lua); - xfree(keys_buf); + char_u *keys_simplified + = replace_termcodes(keys, STRLEN(keys), &keys_buf, flags, &did_simplify, CPO_TO_CPO_FLAGS); + rhs = check_map(keys_simplified, mode, exact, false, abbr, &mp, &buffer_local, &rhs_lua); + if (did_simplify) { + // When the lhs is being simplified the not-simplified keys are + // preferred for printing, like in do_map(). + (void)replace_termcodes(keys, STRLEN(keys), &alt_keys_buf, flags | REPTERM_NO_SIMPLIFY, NULL, + CPO_TO_CPO_FLAGS); + rhs = check_map(alt_keys_buf, mode, exact, false, abbr, &mp, &buffer_local, &rhs_lua); + } if (!get_dict) { // Return a string. @@ -5710,6 +5718,9 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact) mapblock_fill_dict(rettv->vval.v_dict, mp, buffer_local, true); } } + + xfree(keys_buf); + xfree(alt_keys_buf); } /// luaeval() function implementation diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 11ca93cff9..8b47468aad 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -1761,14 +1761,14 @@ char_u *trans_function_name(char_u **pp, bool skip, int flags, funcdict_T *fdp, } else if (lv.ll_tv->v_type == VAR_PARTIAL && lv.ll_tv->vval.v_partial != NULL) { if (is_luafunc(lv.ll_tv->vval.v_partial) && *end == '.') { - len = check_luafunc_name((const char *)end+1, true); + len = check_luafunc_name((const char *)end + 1, true); if (len == 0) { semsg(e_invexpr2, "v:lua"); goto theend; } name = xmallocz((size_t)len); - memcpy(name, end+1, (size_t)len); - *pp = (char_u *)end+1+len; + memcpy(name, end + 1, (size_t)len); + *pp = (char_u *)end + 1 + len; } else { name = vim_strsave(partial_name(lv.ll_tv->vval.v_partial)); *pp = (char_u *)end; @@ -2269,11 +2269,10 @@ void ex_function(exarg_T *eap) } } else { // skip ':' and blanks - for (p = theline; ascii_iswhite(*p) || *p == ':'; p++) { - } + for (p = theline; ascii_iswhite(*p) || *p == ':'; p++) {} // Check for "endfunction". - if (checkforcmd(&p, "endfunction", 4) && nesting-- == 0) { + if (checkforcmd((char **)&p, "endfunction", 4) && nesting-- == 0) { if (*p == '!') { p++; } @@ -2312,7 +2311,7 @@ void ex_function(exarg_T *eap) } // Check for defining a function inside this function. - if (checkforcmd(&p, "function", 2)) { + if (checkforcmd((char **)&p, "function", 2)) { if (*p == '!') { p = skipwhite(p + 1); } @@ -2325,7 +2324,7 @@ void ex_function(exarg_T *eap) } // Check for ":append", ":change", ":insert". - p = skip_range(p, NULL); + p = (char_u *)skip_range((char *)p, NULL); if ((p[0] == 'a' && (!ASCII_ISALPHA(p[1]) || p[1] == 'p')) || (p[0] == 'c' && (!ASCII_ISALPHA(p[1]) |