Patch 8.2.2819

5 views
Skip to first unread message

Bram Moolenaar

unread,
Apr 30, 2021, 1:43:54 PM4/30/21
to vim...@googlegroups.com

Patch 8.2.2819
Problem: Finishing an abbreviation with a multi-byte char may not work.
Solution: Escape K_SPECIAL in the typed character. (closes #8160)
Files: src/map.c, src/testdir/test_mapping.vim


*** ../vim-8.2.2818/src/map.c 2021-04-24 13:12:32.230376646 +0200
--- src/map.c 2021-04-30 19:41:52.022219651 +0200
***************
*** 1540,1549 ****
tb[j++] = Ctrl_V; // special char needs CTRL-V
if (has_mbyte)
{
// if ABBR_OFF has been added, remove it here
if (c >= ABBR_OFF)
c -= ABBR_OFF;
! j += (*mb_char2bytes)(c, tb + j);
}
else
tb[j++] = c;
--- 1540,1562 ----
tb[j++] = Ctrl_V; // special char needs CTRL-V
if (has_mbyte)
{
+ int newlen;
+ char_u *escaped;
+
// if ABBR_OFF has been added, remove it here
if (c >= ABBR_OFF)
c -= ABBR_OFF;
! 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
tb[j++] = c;
*** ../vim-8.2.2818/src/testdir/test_mapping.vim 2021-04-06 20:21:55.299147728 +0200
--- src/testdir/test_mapping.vim 2021-04-30 19:38:03.554634494 +0200
***************
*** 1402,1405 ****
--- 1402,1414 ----
bwipe!
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-8.2.2818/src/version.c 2021-04-29 20:18:41.970795473 +0200
--- src/version.c 2021-04-30 19:38:29.654593115 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2819,
/**/

--
hundred-and-one symptoms of being an internet addict:
199. You read this entire list of symptoms, looking for something
that doesn't describe you.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages