diff options
| author | Ernie Rael <errael@raelity.com> | 2022-04-25 14:40:44 +0100 |
|---|---|---|
| committer | Bram Moolenaar <Bram@vim.org> | 2022-04-25 14:40:44 +0100 |
| commit | 09661203ecefbee6a6f09438afcff1843e9dbfb4 (patch) | |
| tree | e9287958ff8d1d65e4c5a66703cd9f1d16c237fb /src/map.c | |
| parent | 23d5770ef5e2f5c6d20d123303b81327045e5a1e (diff) | |
| download | vim-git-8.2.4825.tar.gz | |
patch 8.2.4825: can only get a list of mappingsv8.2.4825
Problem: Can only get a list of mappings.
Solution: Add the optional {abbr} argument. (Ernie Rael, closes #10277)
Rename to maplist(). Rename test file.
Diffstat (limited to 'src/map.c')
| -rw-r--r-- | src/map.c | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -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]; |
