aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/getchar.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/getchar.c')
-rw-r--r--src/nvim/getchar.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 1d648cb9e9..d0eebf8fea 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -15,6 +15,7 @@
* mappings and abbreviations
*/
+#include <assert.h>
#include <stdbool.h>
#include <string.h>
#include <inttypes.h>
@@ -2980,8 +2981,12 @@ do_map (
}
if (maptype == 1) { /* delete entry */
- if (!did_it)
+ if (!did_it) {
retval = 2; /* no match */
+ } else if (*keys == Ctrl_C) {
+ /* If CTRL-C has been unmapped, reuse it for Interrupting. */
+ mapped_ctrl_c = FALSE;
+ }
goto theend;
}
@@ -3005,7 +3010,7 @@ do_map (
*/
mp = xmalloc(sizeof(mapblock_T));
- /* If CTRL-C has been mapped, don't always use it for Interrupting */
+ /* If CTRL-C has been mapped, don't always use it for Interrupting. */
if (*keys == Ctrl_C)
mapped_ctrl_c = TRUE;
@@ -3633,11 +3638,26 @@ int check_abbr(int c, char_u *ptr, int col, int mincol)
for (; mp;
mp->m_next == NULL ? (mp = mp2, mp2 = NULL) :
(mp = mp->m_next)) {
+ int qlen = mp->m_keylen;
+ char_u *q = mp->m_keys;
+ int match;
+
+ if (vim_strbyte(mp->m_keys, K_SPECIAL) != NULL) {
+ /* might have CSI escaped mp->m_keys */
+ q = vim_strsave(mp->m_keys);
+ vim_unescape_csi(q);
+ qlen = (int)STRLEN(q);
+ }
/* find entries with right mode and keys */
- if ( (mp->m_mode & State)
- && mp->m_keylen == len
- && !STRNCMP(mp->m_keys, ptr, (size_t)len))
+ match = (mp->m_mode & State)
+ && qlen == len
+ && !STRNCMP(q, ptr, (size_t)len);
+ if (q != mp->m_keys) {
+ free(q);
+ }
+ if (match) {
break;
+ }
}
if (mp != NULL) {
/*