aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/getchar.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-05-17 02:13:31 +0200
committerGitHub <noreply@github.com>2018-05-17 02:13:31 +0200
commit2aa308c6852b7c51caef5dd6dc4e809719ca7a55 (patch)
treea01a72b5ccd7bc00acb7db74397608a85a4aba95 /src/nvim/getchar.c
parentde7a0bdc35922d4f529bd4b28f992177152d4562 (diff)
parent9058a5a19a3f62fb156203e0226eaaabb8b8da56 (diff)
downloadrneovim-2aa308c6852b7c51caef5dd6dc4e809719ca7a55.tar.gz
rneovim-2aa308c6852b7c51caef5dd6dc4e809719ca7a55.tar.bz2
rneovim-2aa308c6852b7c51caef5dd6dc4e809719ca7a55.zip
Merge #5658 'Apply :lmap in macros'
Diffstat (limited to 'src/nvim/getchar.c')
-rw-r--r--src/nvim/getchar.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index e2566c8c66..07a65c2611 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -1852,8 +1852,11 @@ static int vgetorpeek(int advance)
keylen = KEYLEN_PART_MAP;
break;
}
- } else if (keylen > mp_match_len) {
- /* found a longer match */
+ } else if (keylen > mp_match_len
+ || (keylen == mp_match_len
+ && (mp_match->m_mode & LANGMAP) == 0
+ && (mp->m_mode & LANGMAP) != 0)) {
+ // found a longer match
mp_match = mp;
mp_match_len = keylen;
}
@@ -1947,8 +1950,9 @@ static int vgetorpeek(int advance)
char_u *save_m_keys;
char_u *save_m_str;
- // write chars to script file(s)
- if (keylen > typebuf.tb_maplen) {
+ // Write chars to script file(s)
+ // Note: :lmap mappings are written *after* being applied. #5658
+ if (keylen > typebuf.tb_maplen && (mp->m_mode & LANGMAP) == 0) {
gotchars(typebuf.tb_buf + typebuf.tb_off + typebuf.tb_maplen,
(size_t)(keylen - typebuf.tb_maplen));
}
@@ -2023,6 +2027,12 @@ static int vgetorpeek(int advance)
else {
int noremap;
+ // If this is a LANGMAP mapping, then we didn't record the keys
+ // at the start of the function and have to record them now.
+ if (keylen > typebuf.tb_maplen && (mp->m_mode & LANGMAP) != 0) {
+ gotchars(s, STRLEN(s));
+ }
+
if (save_m_noremap != REMAP_YES)
noremap = save_m_noremap;
else if (