diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-05-05 21:53:10 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-05-05 22:06:10 -0400 |
commit | dd935e147344d90d42710c144822259a6af6f090 (patch) | |
tree | c0e7cb8dff91b95cf1d01989edf7048a38ad23b3 /src | |
parent | 8a93d1028f38c77d7ad8b4ad0a93dc11a5cbe85d (diff) | |
download | rneovim-dd935e147344d90d42710c144822259a6af6f090.tar.gz rneovim-dd935e147344d90d42710c144822259a6af6f090.tar.bz2 rneovim-dd935e147344d90d42710c144822259a6af6f090.zip |
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)
https://github.com/vim/vim/commit/4934ed34c3e2090d1963c89c629cd3ce81d3ecd1
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/getchar.c | 11 | ||||
-rw-r--r-- | src/nvim/testdir/test_mapping.vim | 9 |
2 files changed, 19 insertions, 1 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 9afce6e9d5..bb406a68c5 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -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 diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim index 0191dbf33e..f88e8cf843 100644 --- a/src/nvim/testdir/test_mapping.vim +++ b/src/nvim/testdir/test_mapping.vim @@ -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 |