diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-04-30 17:14:00 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-04-30 22:27:27 +0800 |
commit | db355ca4e5d1f8c3e1b749ca21336a7ebbab7317 (patch) | |
tree | 1500dc7d3629a10f67eb98a0c7d17f03a045daa3 | |
parent | fcdf24d8be4abada88355538a23d771e41c77dd4 (diff) | |
download | rneovim-db355ca4e5d1f8c3e1b749ca21336a7ebbab7317.tar.gz rneovim-db355ca4e5d1f8c3e1b749ca21336a7ebbab7317.tar.bz2 rneovim-db355ca4e5d1f8c3e1b749ca21336a7ebbab7317.zip |
vim-patch:8.1.2191: when using modifyOtherKeys CTRL-X mode may not work
Problem: When using modifyOtherKeys CTRL-X mode may not work.
Solution: Recognize a control character also in the form with a modifier.
https://github.com/vim/vim/commit/88d3d09e07dbe0e3ea450bc554e2aadc451450d2
-rw-r--r-- | src/nvim/getchar.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 7d06164c89..9af03208b4 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -1768,6 +1768,19 @@ static int put_string_in_typebuf(int offset, int slen, char_u *string, int new_s return OK; } +/// Check if the bytes at the start of the typeahead buffer are a character used +/// in CTRL-X mode. This includes the form with a CTRL modifier. +static bool at_ctrl_x_key(void) +{ + char_u *p = typebuf.tb_buf + typebuf.tb_off; + int c = *p; + + if (typebuf.tb_len > 3 && c == K_SPECIAL && p[1] == KS_MODIFIER && (p[2] & MOD_MASK_CTRL)) { + c = p[3] & 0x1f; + } + return vim_is_ctrl_x_key(c); +} + /// Check if typebuf.tb_buf[] contains a modifer plus key that can be changed /// into just a key, apply that. /// Check from typebuf.tb_buf[typebuf.tb_off] to typebuf.tb_buf[typebuf.tb_off + "max_offset"]. @@ -1870,7 +1883,7 @@ static int handle_mapping(int *keylenp, bool *timedout, int *mapdepth) && !(State == HITRETURN && (tb_c1 == CAR || tb_c1 == ' ')) && State != ASKMORE && State != CONFIRM - && !((ctrl_x_mode_not_default() && vim_is_ctrl_x_key(tb_c1)) + && !((ctrl_x_mode_not_default() && at_ctrl_x_key()) || ((compl_cont_status & CONT_LOCAL) && (tb_c1 == Ctrl_N || tb_c1 == Ctrl_P)))) { if (tb_c1 == K_SPECIAL) { |