1
0
forked from aniani/vim

patch 8.2.4825: can only get a list of mappings

Problem:    Can only get a list of mappings.
Solution:   Add the optional {abbr} argument. (Ernie Rael, closes #10277)
            Rename to maplist().  Rename test file.
This commit is contained in:
Ernie Rael
2022-04-25 14:40:44 +01:00
committed by Bram Moolenaar
parent 23d5770ef5
commit 09661203ec
8 changed files with 74 additions and 40 deletions

View File

@@ -2389,10 +2389,10 @@ get_maparg(typval_T *argvars, typval_T *rettv, int exact)
}
/*
* "getmappings()" function
* "maplist()" function
*/
void
f_getmappings(typval_T *argvars UNUSED, typval_T *rettv)
f_maplist(typval_T *argvars UNUSED, typval_T *rettv)
{
dict_T *d;
mapblock_T *mp;
@@ -2402,6 +2402,12 @@ f_getmappings(typval_T *argvars UNUSED, typval_T *rettv)
int hash;
char_u *lhs;
const int flags = REPTERM_FROM_PART | REPTERM_DO_LT;
int abbr = FALSE;
if (in_vim9script() && check_for_opt_bool_arg(argvars, 0) == FAIL)
return;
if (argvars[0].v_type != VAR_UNKNOWN)
abbr = tv_get_bool(&argvars[0]);
if (rettv_list_alloc(rettv) != OK)
return;
@@ -2413,7 +2419,16 @@ f_getmappings(typval_T *argvars UNUSED, typval_T *rettv)
{
for (hash = 0; hash < 256; ++hash)
{
if (buffer_local)
if (abbr)
{
if (hash > 0) // there is only one abbr list
break;
if (buffer_local)
mp = curbuf->b_first_abbr;
else
mp = first_abbr;
}
else if (buffer_local)
mp = curbuf->b_maphash[hash];
else
mp = maphash[hash];