summaryrefslogtreecommitdiffstats
path: root/src/map.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-04-24 13:12:38 +0200
committerBram Moolenaar <Bram@vim.org>2021-04-24 13:12:38 +0200
commit7ba1e4d363164e32a93cceab64b42e8c6d89e9f3 (patch)
tree394f63849ccd92fab02124387392df2aa77f75a2 /src/map.c
parente0c03c8e107f109eadab145e18544d8e74a6976e (diff)
patch 8.2.2804: setting buffer local mapping with mapset() changes globalv8.2.2804
Problem: Setting buffer local mapping with mapset() changes global mapping. Solution: Only set the local mapping. (closes #8143)
Diffstat (limited to 'src/map.c')
-rw-r--r--src/map.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/map.c b/src/map.c
index 917f1a244f..f142db09c4 100644
--- a/src/map.c
+++ b/src/map.c
@@ -2295,6 +2295,7 @@ f_mapset(typval_T *argvars, typval_T *rettv UNUSED)
int noremap;
int expr;
int silent;
+ int buffer;
scid_T sid;
linenr_T lnum;
mapblock_T **map_table = maphash;
@@ -2336,18 +2337,31 @@ f_mapset(typval_T *argvars, typval_T *rettv UNUSED)
silent = dict_get_number(d, (char_u *)"silent") != 0;
sid = dict_get_number(d, (char_u *)"sid");
lnum = dict_get_number(d, (char_u *)"lnum");
- if (dict_get_number(d, (char_u *)"buffer"))
+ buffer = dict_get_number(d, (char_u *)"buffer");
+ nowait = dict_get_number(d, (char_u *)"nowait") != 0;
+ // mode from the dict is not used
+
+ if (buffer)
{
map_table = curbuf->b_maphash;
abbr_table = &curbuf->b_first_abbr;
}
- nowait = dict_get_number(d, (char_u *)"nowait") != 0;
- // mode from the dict is not used
// Delete any existing mapping for this lhs and mode.
- arg = vim_strsave(lhs);
- if (arg == NULL)
- return;
+ if (buffer)
+ {
+ arg = alloc(STRLEN(lhs) + STRLEN("<buffer>") + 1);
+ if (arg == NULL)
+ return;
+ STRCPY(arg, "<buffer>");
+ STRCPY(arg + 8, lhs);
+ }
+ else
+ {
+ arg = vim_strsave(lhs);
+ if (arg == NULL)
+ return;
+ }
do_map(1, arg, mode, is_abbr);
vim_free(arg);