diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-05-07 08:34:37 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2023-05-08 01:12:09 +0800 |
commit | 32331378134599ece34298f866889b4b311d7b79 (patch) | |
tree | 62bee36d873793ac3c306baa804df6e31d12cb70 /src | |
parent | 29c228dc1087676af5b72f4145ab146cff75156e (diff) | |
download | rneovim-32331378134599ece34298f866889b4b311d7b79.tar.gz rneovim-32331378134599ece34298f866889b4b311d7b79.tar.bz2 rneovim-32331378134599ece34298f866889b4b311d7b79.zip |
vim-patch:9.0.1516: cannot use special keys in <Cmd> mapping
Problem: Cannot use special keys in <Cmd> mapping.
Solution: Do allow for special keys in <Cmd> and <ScriptCmd> mappings.
(closes vim/vim#12326)
https://github.com/vim/vim/commit/3ab3a864814f903da8a158c01820e4fbe1013c08
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/getchar.c | 20 | ||||
-rw-r--r-- | src/nvim/ops.c | 2 |
2 files changed, 16 insertions, 6 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 07d7887fc6..c070e53089 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -554,6 +554,21 @@ void AppendToRedobuffLit(const char *str, int len) } } +/// Append "s" to the redo buffer, leaving 3-byte special key codes unmodified +/// and escaping other K_SPECIAL bytes. +void AppendToRedobuffSpec(const char *s) +{ + while (*s != NUL) { + if ((uint8_t)(*s) == K_SPECIAL && s[1] != NUL && s[2] != NUL) { + // Insert special key literally. + add_buff(&redobuff, s, 3L); + s += 3; + } else { + add_char_buff(&redobuff, mb_cptr2char_adv(&s)); + } + } +} + /// Append a character to the redo buffer. /// Translates special keys, NUL, K_SPECIAL and multibyte characters. void AppendCharToRedobuff(int c) @@ -2927,11 +2942,6 @@ char *getcmdkeycmd(int promptc, void *cookie, int indent, bool do_concat) } c1 = TO_SPECIAL(c1, c2); } - if (c1 == Ctrl_V) { - // CTRL-V is followed by octal, hex or other characters, reverses - // what AppendToRedobuffLit() does. - c1 = get_literal(true); - } if (got_int) { aborted = true; diff --git a/src/nvim/ops.c b/src/nvim/ops.c index bb66bb5731..ef26d5900d 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -5858,7 +5858,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) if (repeat_cmdline == NULL) { ResetRedobuff(); } else { - AppendToRedobuffLit(repeat_cmdline, -1); + AppendToRedobuffSpec(repeat_cmdline); AppendToRedobuff(NL_STR); XFREE_CLEAR(repeat_cmdline); } |