changeset 24375:fe4b6fc7149c v8.2.2728

patch 8.2.2728: special key names don't work if 'isident' is cleared Commit: https://github.com/vim/vim/commit/e3d1f4c982bd0fe05496448d7868268c75ff7bfb Author: Bram Moolenaar <Bram@vim.org> Date: Tue Apr 6 20:21:59 2021 +0200 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)
author Bram Moolenaar <Bram@vim.org>
date Tue, 06 Apr 2021 20:30:05 +0200
parents feb7899419e7
children d9b9f9e0c7ee
files src/charset.c src/misc2.c src/proto/charset.pro src/testdir/test_mapping.vim src/version.c
diffstat 5 files changed, 20 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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).
--- 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;
--- 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);
--- 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',
--- 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,