mirror of
https://github.com/neovim/neovim.git
synced 2026-06-15 08:13:45 +00:00
vim-patch:9.2.0629: 0x80 and 0x9b byte not unescaped when check for valid abbr
Problem: 0x80 and 0x9b byte not unescaped when checking for valid abbr
(Mao-Yining)
Solution: Use mb_unescape() (zeertzjq).
fixes: vim/vim#20506
closes: vim/vim#20508
1958c991a8
This commit is contained in:
@@ -628,17 +628,24 @@ static int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev,
|
||||
// vi-compatible way.
|
||||
int same = -1;
|
||||
|
||||
const int first = vim_iswordp(lhs);
|
||||
const char *p = lhs;
|
||||
const char *p_char = mb_unescape(&p);
|
||||
if (p_char == NULL) {
|
||||
p_char = p++;
|
||||
}
|
||||
const int first = vim_iswordp(p_char);
|
||||
int last = first;
|
||||
const char *p = lhs + utfc_ptr2len(lhs);
|
||||
int n = 1;
|
||||
while (p < lhs + len) {
|
||||
n++; // nr of (multi-byte) chars
|
||||
last = vim_iswordp(p); // type of last char
|
||||
p_char = mb_unescape(&p);
|
||||
if (p_char == NULL) {
|
||||
p_char = p++;
|
||||
}
|
||||
last = vim_iswordp(p_char); // type of last char
|
||||
if (same == -1 && last != first) {
|
||||
same = n - 1; // count of same char type
|
||||
}
|
||||
p += utfc_ptr2len(p);
|
||||
}
|
||||
if (last && n > 2 && same >= 0 && same < n - 1) {
|
||||
retval = 1;
|
||||
|
||||
@@ -7,11 +7,29 @@ source term_util.vim
|
||||
|
||||
func Test_abbreviation()
|
||||
new
|
||||
" abbreviation with 0x80 should work
|
||||
|
||||
" abbreviation with 0x80 (full-id)
|
||||
inoreab чкпр vim
|
||||
call feedkeys("Goчкпр \<Esc>", "xt")
|
||||
call assert_equal('vim ', getline('$'))
|
||||
iunab чкпр
|
||||
|
||||
" abbreviation with 0x80 (non-id)
|
||||
inoreab abc⁀ abc^
|
||||
inoreab ⁀ ^
|
||||
call feedkeys("Goabc⁀ def⁀ ⁀ \<Esc>", "xt")
|
||||
call assert_equal('abc^ def⁀ ^ ', getline('$'))
|
||||
iunab abc⁀
|
||||
iunab ⁀
|
||||
|
||||
" abbreviation with 0x9b (non-id)
|
||||
inoreab abc; abc;
|
||||
inoreab ; ;
|
||||
call feedkeys("Goabc; def; ; \<Esc>", "xt")
|
||||
call assert_equal('abc; def; ; ', getline('$'))
|
||||
iunab abc;
|
||||
iunab ;
|
||||
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
|
||||
Reference in New Issue
Block a user