summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2013-06-29 13:58:31 +0200
committerBram Moolenaar <Bram@vim.org>2013-06-29 13:58:31 +0200
commit72179e1bd0bbb1d1c3083c85bd9fb0a8d6928f7f (patch)
tree8c591c38ab393b0c2967bf9037054b7420a7ddf5 /src
parentb751546636c71f206733af1bc30415aaab9a0b42 (diff)
downloadvim-72179e1bd0bbb1d1c3083c85bd9fb0a8d6928f7f.zip
updated for version 7.3.1261
Problem: A buffer-local language mapping from a keymap stops a global insert mode mapping from working. (Ron Aaron) Solution: Do not wait for more characters to be typed only when the mapping was defined with <nowait>.
Diffstat (limited to 'src')
-rw-r--r--src/eval.c1
-rw-r--r--src/getchar.c43
-rw-r--r--src/testdir/test75.in2
-rw-r--r--src/testdir/test75.ok5
-rw-r--r--src/version.c2
5 files changed, 36 insertions, 17 deletions
diff --git a/src/eval.c b/src/eval.c
index 19b4479b6..5cac7b4ad 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -13735,6 +13735,7 @@ get_maparg(argvars, rettv, exact)
dict_add_nr_str(dict, "silent", mp->m_silent ? 1L : 0L, NULL);
dict_add_nr_str(dict, "sid", (long)mp->m_script_ID, NULL);
dict_add_nr_str(dict, "buffer", (long)buffer_local, NULL);
+ dict_add_nr_str(dict, "nowait", mp->m_nowait ? 1L : 0L, NULL);
dict_add_nr_str(dict, "mode", 0L, mapmode);
vim_free(lhs);
diff --git a/src/getchar.c b/src/getchar.c
index e24a6abcf..fe6423d3d 100644
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -1924,7 +1924,6 @@ vgetorpeek(advance)
mapblock_T *mp;
#ifdef FEAT_LOCALMAP
mapblock_T *mp2;
- int expecting_global_mappings;
#endif
mapblock_T *mp_match;
int mp_match_len = 0;
@@ -2106,9 +2105,9 @@ vgetorpeek(advance)
/* First try buffer-local mappings. */
mp = curbuf->b_maphash[MAP_HASH(local_State, c1)];
mp2 = maphash[MAP_HASH(local_State, c1)];
- expecting_global_mappings = (mp && mp2);
if (mp == NULL)
{
+ /* There are no buffer-local mappings. */
mp = mp2;
mp2 = NULL;
}
@@ -2130,16 +2129,6 @@ vgetorpeek(advance)
#endif
(mp = mp->m_next))
{
-#ifdef FEAT_LOCALMAP
- if (expecting_global_mappings && mp2 == NULL)
- {
- /* This is the first global mapping. If we've
- * got a complete buffer-local match, use it. */
- if (mp_match)
- break;
- expecting_global_mappings = FALSE;
- }
-#endif
/*
* Only consider an entry if the first character
* matches and it is for the current state.
@@ -2215,7 +2204,8 @@ vgetorpeek(advance)
if (keylen > typebuf.tb_len)
{
- if (!timedout)
+ if (!timedout && !(mp_match != NULL
+ && mp_match->m_nowait))
{
/* break at a partly match */
keylen = KEYLEN_PART_MAP;
@@ -3207,6 +3197,7 @@ do_map(maptype, arg, mode, abbrev)
mapblock_T **abbr_table;
mapblock_T **map_table;
int unique = FALSE;
+ int nowait = FALSE;
int silent = FALSE;
int special = FALSE;
#ifdef FEAT_EVAL
@@ -3225,7 +3216,8 @@ do_map(maptype, arg, mode, abbrev)
else
noremap = REMAP_YES;
- /* Accept <buffer>, <silent>, <expr> <script> and <unique> in any order. */
+ /* Accept <buffer>, <nowait>, <silent>, <expr> <script> and <unique> in
+ * any order. */
for (;;)
{
#ifdef FEAT_LOCALMAP
@@ -3242,6 +3234,16 @@ do_map(maptype, arg, mode, abbrev)
#endif
/*
+ * Check for "<nowait>": don't wait for more characters.
+ */
+ if (STRNCMP(keys, "<nowait>", 8) == 0)
+ {
+ keys = skipwhite(keys + 8);
+ nowait = TRUE;
+ continue;
+ }
+
+ /*
* Check for "<silent>": don't echo commands.
*/
if (STRNCMP(keys, "<silent>", 8) == 0)
@@ -3607,6 +3609,7 @@ do_map(maptype, arg, mode, abbrev)
vim_free(mp->m_orig_str);
mp->m_orig_str = vim_strsave(orig_rhs);
mp->m_noremap = noremap;
+ mp->m_nowait = nowait;
mp->m_silent = silent;
mp->m_mode = mode;
#ifdef FEAT_EVAL
@@ -3695,6 +3698,7 @@ do_map(maptype, arg, mode, abbrev)
}
mp->m_keylen = (int)STRLEN(mp->m_keys);
mp->m_noremap = noremap;
+ mp->m_nowait = nowait;
mp->m_silent = silent;
mp->m_mode = mode;
#ifdef FEAT_EVAL
@@ -4173,6 +4177,11 @@ set_context_in_map_cmd(xp, cmd, arg, forceit, isabbrev, isunmap, cmdidx)
arg = skipwhite(arg + 8);
continue;
}
+ if (STRNCMP(arg, "<nowait>", 8) == 0)
+ {
+ arg = skipwhite(arg + 8);
+ continue;
+ }
if (STRNCMP(arg, "<silent>", 8) == 0)
{
arg = skipwhite(arg + 8);
@@ -4229,7 +4238,7 @@ ExpandMappings(regmatch, num_file, file)
{
count = 0;
- for (i = 0; i < 5; ++i)
+ for (i = 0; i < 6; ++i)
{
if (i == 0)
p = (char_u *)"<silent>";
@@ -4245,6 +4254,8 @@ ExpandMappings(regmatch, num_file, file)
else if (i == 4 && !expand_buffer)
p = (char_u *)"<buffer>";
#endif
+ else if (i == 5)
+ p = (char_u *)"<nowait>";
else
continue;
@@ -4857,6 +4868,8 @@ makemap(fd, buf)
return FAIL;
if (buf != NULL && fputs(" <buffer>", fd) < 0)
return FAIL;
+ if (mp->m_nowait && fputs(" <nowait>", fd) < 0)
+ return FAIL;
if (mp->m_silent && fputs(" <silent>", fd) < 0)
return FAIL;
#ifdef FEAT_EVAL
diff --git a/src/testdir/test75.in b/src/testdir/test75.in
index 5369d8a3d..f43970dc6 100644
--- a/src/testdir/test75.in
+++ b/src/testdir/test75.in
@@ -9,6 +9,8 @@ STARTTEST
:call append('$', maparg('foo<C-V>'))
:call append('$', string(maparg('foo<C-V>', '', 0, 1)))
:call append('$', string(maparg('bar', '', 0, 1)))
+:map <buffer> <nowait> foo bar
+:call append('$', string(maparg('foo', '', 0, 1)))
:"
:map abc x<char-114>x
:call append('$', maparg('abc'))
diff --git a/src/testdir/test75.ok b/src/testdir/test75.ok
index af9c96de8..d8f9a2aad 100644
--- a/src/testdir/test75.ok
+++ b/src/testdir/test75.ok
@@ -1,5 +1,6 @@
is<F4>foo
-{'silent': 0, 'noremap': 0, 'lhs': 'foo<C-V>', 'mode': ' ', 'expr': 0, 'sid': 0, 'rhs': 'is<F4>foo', 'buffer': 0}
-{'silent': 1, 'noremap': 1, 'lhs': 'bar', 'mode': 'v', 'expr': 1, 'sid': 0, 'rhs': 'isbar', 'buffer': 1}
+{'silent': 0, 'noremap': 0, 'lhs': 'foo<C-V>', 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': 0, 'rhs': 'is<F4>foo', 'buffer': 0}
+{'silent': 1, 'noremap': 1, 'lhs': 'bar', 'mode': 'v', 'nowait': 0, 'expr': 1, 'sid': 0, 'rhs': 'isbar', 'buffer': 1}
+{'silent': 0, 'noremap': 0, 'lhs': 'foo', 'mode': ' ', 'nowait': 1, 'expr': 0, 'sid': 0, 'rhs': 'bar', 'buffer': 1}
xrx
yRy
diff --git a/src/version.c b/src/version.c
index 60d0d10da..7fbb0eef6 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1261,
+/**/
1260,
/**/
1259,