0
0
mirror of https://github.com/vim/vim.git synced 2025-10-06 05:44:14 -04:00

patch 8.2.2819: finishing an abbreviation with multi-byte char may not work

Problem:    Finishing an abbreviation with a multi-byte char may not work.
Solution:   Escape K_SPECIAL in the typed character. (closes #8160)
This commit is contained in:
Bram Moolenaar
2021-04-30 19:43:11 +02:00
parent aeed2a6359
commit 4934ed34c3
3 changed files with 25 additions and 1 deletions

View File

@@ -1540,10 +1540,23 @@ check_abbr(
tb[j++] = Ctrl_V; // special char needs CTRL-V tb[j++] = Ctrl_V; // special char needs CTRL-V
if (has_mbyte) if (has_mbyte)
{ {
int newlen;
char_u *escaped;
// if ABBR_OFF has been added, remove it here // if ABBR_OFF has been added, remove it here
if (c >= ABBR_OFF) if (c >= ABBR_OFF)
c -= ABBR_OFF; c -= ABBR_OFF;
j += (*mb_char2bytes)(c, tb + j); newlen = (*mb_char2bytes)(c, tb + j);
tb[j + newlen] = NUL;
// Need to escape K_SPECIAL.
escaped = vim_strsave_escape_csi(tb + j);
if (escaped != NULL)
{
newlen = STRLEN(escaped);
mch_memmove(tb + j, escaped, newlen);
j += newlen;
vim_free(escaped);
}
} }
else else
tb[j++] = c; tb[j++] = c;

View File

@@ -1402,4 +1402,13 @@ func Test_script_local_remap()
bwipe! bwipe!
endfunc endfunc
func Test_abbreviate_multi_byte()
new
iabbrev foo bar
call feedkeys("ifoo…\<Esc>", 'xt')
call assert_equal("bar…", getline(1))
iunabbrev foo
bwipe!
endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

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