patch 8.2.2728: special key names don't work if 'isident' is cleared
Problem: Special key names don't work if 'isident' is cleared.
Solution: Add vim_isNormalIDc() and use it for special key names.
(closes #2389)
diff --git a/src/charset.c b/src/charset.c
index db0c146..10aa2e8 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -835,6 +835,16 @@
}
/*
+ * Like vim_isIDc() but not using the 'isident' option: letters, numbers and
+ * underscore.
+ */
+ int
+vim_isNormalIDc(int c)
+{
+ return ASCII_ISALNUM(c) || c == '_';
+}
+
+/*
* return TRUE if 'c' is a keyword character: Letters and characters from
* 'iskeyword' option for the current buffer.
* For multi-byte characters mb_get_class() is used (builtin rules).
diff --git a/src/misc2.c b/src/misc2.c
index 90b8b58..08e6ed9 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -2826,7 +2826,7 @@
// Find end of modifier list
last_dash = src;
- for (bp = src + 1; *bp == '-' || vim_isIDc(*bp); bp++)
+ for (bp = src + 1; *bp == '-' || vim_isNormalIDc(*bp); bp++)
{
if (*bp == '-')
{
@@ -3121,10 +3121,10 @@
for (i = 0; key_names_table[i].name != NULL; i++)
{
table_name = key_names_table[i].name;
- for (j = 0; vim_isIDc(name[j]) && table_name[j] != NUL; j++)
+ for (j = 0; vim_isNormalIDc(name[j]) && table_name[j] != NUL; j++)
if (TOLOWER_ASC(table_name[j]) != TOLOWER_ASC(name[j]))
break;
- if (!vim_isIDc(name[j]) && table_name[j] == NUL)
+ if (!vim_isNormalIDc(name[j]) && table_name[j] == NUL)
return key_names_table[i].key;
}
return 0;
diff --git a/src/proto/charset.pro b/src/proto/charset.pro
index d364b8e..883f393 100644
--- a/src/proto/charset.pro
+++ b/src/proto/charset.pro
@@ -19,6 +19,7 @@
int linetabsize_col(int startcol, char_u *s);
int win_linetabsize(win_T *wp, char_u *line, colnr_T len);
int vim_isIDc(int c);
+int vim_isNormalIDc(int c);
int vim_iswordc(int c);
int vim_iswordc_buf(int c, buf_T *buf);
int vim_iswordp(char_u *p);
diff --git a/src/testdir/test_mapping.vim b/src/testdir/test_mapping.vim
index d7e4caa..c93562b 100644
--- a/src/testdir/test_mapping.vim
+++ b/src/testdir/test_mapping.vim
@@ -445,9 +445,12 @@
" Remove default mappings
imapclear
- inoremap <C-M> CtrlM
+ " reset 'isident' to check it isn't used
+ set isident=
+ inoremap <C-m> CtrlM
inoremap <A-S> AltS
inoremap <S-/> ShiftSlash
+ set isident&
call assert_equal([
\ 'i <S-/> * ShiftSlash',
\ 'i <M-S> * AltS',
diff --git a/src/version.c b/src/version.c
index 0abdbe5..f041987 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2728,
+/**/
2727,
/**/
2726,