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.
diff --git a/src/map.c b/src/map.c
index b2f9dcf..c7de5a1 100644
--- a/src/map.c
+++ b/src/map.c
@@ -2389,10 +2389,10 @@
}
/*
- * "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 @@
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 @@
{
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];