From: Bram Moolenaar Date: Tue, 6 Apr 2021 18:21:59 +0000 (+0200) Subject: patch 8.2.2728: special key names don't work if 'isident' is cleared X-Git-Tag: v8.2.2728 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e3d1f4c982bd0fe05496448d7868268c75ff7bfb;p=vim 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 db0c146f8..10aa2e8e5 100644 --- a/src/charset.c +++ b/src/charset.c @@ -834,6 +834,16 @@ vim_isIDc(int c) return (c > 0 && c < 0x100 && (g_chartab[c] & CT_ID_CHAR)); } +/* + * 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. 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 CtrlM + " reset 'isident' to check it isn't used + set isident= + inoremap CtrlM inoremap AltS inoremap ShiftSlash + set isident& call assert_equal([ \ 'i * ShiftSlash', \ 'i * AltS', diff --git a/src/version.c b/src/version.c index 0abdbe50c..f04198784 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2728, /**/ 2727, /**/