summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-04-06 20:21:59 +0200
committerBram Moolenaar <Bram@vim.org>2021-04-06 20:21:59 +0200
commite3d1f4c982bd0fe05496448d7868268c75ff7bfb (patch)
treee272320895bfe5bc0c6d175ddcd213370d354ae0
parente9b8b78e046b40b877c999432c4698edb3413d5d (diff)
downloadvim-git-e3d1f4c982bd0fe05496448d7868268c75ff7bfb.tar.gz
patch 8.2.2728: special key names don't work if 'isident' is clearedv8.2.2728
Problem: Special key names don't work if 'isident' is cleared. Solution: Add vim_isNormalIDc() and use it for special key names. (closes #2389)
-rw-r--r--src/charset.c10
-rw-r--r--src/misc2.c6
-rw-r--r--src/proto/charset.pro1
-rw-r--r--src/testdir/test_mapping.vim5
-rw-r--r--src/version.c2
5 files changed, 20 insertions, 4 deletions
diff --git a/src/charset.c b/src/charset.c
index db0c146f8..10aa2e8e5 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -835,6 +835,16 @@ vim_isIDc(int c)
}
/*
+ * 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 90b8b5893..08e6ed936 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -2826,7 +2826,7 @@ find_special_key(
// 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 @@ get_special_key_code(char_u *name)
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 d364b8e49..883f39300 100644
--- a/src/proto/charset.pro
+++ b/src/proto/charset.pro
@@ -19,6 +19,7 @@ int linetabsize(char_u *s);
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 d7e4caa91..c93562b07 100644
--- a/src/testdir/test_mapping.vim
+++ b/src/testdir/test_mapping.vim
@@ -445,9 +445,12 @@ func Test_list_mappings()
" 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 0abdbe50c..f04198784 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2728,
+/**/
2727,
/**/
2726,