Mercurial > vim
diff src/misc2.c @ 28668:53c608c7ea9e v8.2.4858
patch 8.2.4858: K_SPECIAL may be escaped twice
Commit: https://github.com/vim/vim/commit/db08887f24d20be11d184ce321bc0890613e42bd
Author: zeertzjq <zeertzjq@outlook.com>
Date: Mon May 2 22:53:45 2022 +0100
patch 8.2.4858: K_SPECIAL may be escaped twice
Problem: K_SPECIAL may be escaped twice.
Solution: Avoid double escaping. (closes https://github.com/vim/vim/issues/10340)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 03 May 2022 00:00:04 +0200 |
parents | ce202d2984a0 |
children | d770568e6c98 |
line wrap: on
line diff
--- a/src/misc2.c +++ b/src/misc2.c @@ -1265,6 +1265,7 @@ trans_special( char_u **srcp, char_u *dst, int flags, // FSK_ values + int escape_ks, // escape K_SPECIAL bytes in the character int *did_simplify) // FSK_SIMPLIFY and found <C-H> or <A-x> { int modifiers = 0; @@ -1274,18 +1275,18 @@ trans_special( if (key == 0) return 0; - return special_to_buf(key, modifiers, flags & FSK_KEYCODE, dst); + return special_to_buf(key, modifiers, escape_ks, dst); } /* * Put the character sequence for "key" with "modifiers" into "dst" and return * the resulting length. - * When "keycode" is TRUE prefer key code, e.g. K_DEL instead of DEL. + * When "escape_ks" is TRUE escape K_SPECIAL bytes in the character. * The sequence is not NUL terminated. * This is how characters in a string are encoded. */ int -special_to_buf(int key, int modifiers, int keycode, char_u *dst) +special_to_buf(int key, int modifiers, int escape_ks, char_u *dst) { int dlen = 0; @@ -1303,10 +1304,10 @@ special_to_buf(int key, int modifiers, i dst[dlen++] = KEY2TERMCAP0(key); dst[dlen++] = KEY2TERMCAP1(key); } - else if (has_mbyte && !keycode) + else if (escape_ks) + dlen = (int)(add_char2buf(key, dst + dlen) - dst); + else if (has_mbyte) dlen += (*mb_char2bytes)(key, dst + dlen); - else if (keycode) - dlen = (int)(add_char2buf(key, dst + dlen) - dst); else dst[dlen++] = key;