vim-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 vim/vim#8160)
4934ed34c3
This commit is contained in:
Jan Edmund Lazo 2021-05-05 21:53:10 -04:00
parent 8a93d1028f
commit dd935e1473
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15
2 changed files with 19 additions and 1 deletions

View File

@ -3831,7 +3831,16 @@ bool check_abbr(int c, char_u *ptr, int col, int mincol)
if (c >= ABBR_OFF) {
c -= ABBR_OFF;
}
j += utf_char2bytes(c, tb + j);
int newlen = utf_char2bytes(c, tb + j);
tb[j + newlen] = NUL;
// Need to escape K_SPECIAL.
char_u *escaped = vim_strsave_escape_csi(tb + j);
if (escaped != NULL) {
newlen = (int)STRLEN(escaped);
memmove(tb + j, escaped, (size_t)newlen);
j += newlen;
xfree(escaped);
}
}
tb[j] = NUL;
// insert the last typed char

View File

@ -559,4 +559,13 @@ func Test_map_cmdkey_redo()
ounmap i-
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