0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

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)
This commit is contained in:
Bram Moolenaar
2021-04-06 20:21:59 +02:00
parent e9b8b78e04
commit e3d1f4c982
5 changed files with 20 additions and 4 deletions

View File

@@ -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.

View File

@@ -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;

View File

@@ -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);

View File

@@ -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',

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2728,
/**/
2727,
/**/