diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/getchar.c | 18 | ||||
-rw-r--r-- | src/nvim/testdir/test_filetype.vim | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test_popup.vim | 15 |
3 files changed, 31 insertions, 3 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 7d06164c89..6dd6c51e8f 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -1768,6 +1768,20 @@ 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 Insert mode completion. This includes the form with a CTRL modifier. +static bool at_ins_compl_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 (ctrl_x_mode_not_default() && vim_is_ctrl_x_key(c)) + || ((compl_cont_status & CONT_LOCAL) && (c == Ctrl_N || c == Ctrl_P)); +} + /// 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,9 +1884,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)) - || ((compl_cont_status & CONT_LOCAL) - && (tb_c1 == Ctrl_N || tb_c1 == Ctrl_P)))) { + && !at_ins_compl_key()) { if (tb_c1 == K_SPECIAL) { nolmaplen = 2; } else { diff --git a/src/nvim/testdir/test_filetype.vim b/src/nvim/testdir/test_filetype.vim index 6872eb3bb7..6ae957da70 100644 --- a/src/nvim/testdir/test_filetype.vim +++ b/src/nvim/testdir/test_filetype.vim @@ -211,6 +211,7 @@ let s:filename_checks = { \ 'gitrebase': ['git-rebase-todo'], \ 'gitsendemail': ['.gitsendemail.msg.xxxxxx'], \ 'gkrellmrc': ['gkrellmrc', 'gkrellmrc_x'], + \ 'gleam': ['file.gleam'], \ 'glsl': ['file.glsl'], \ 'gnash': ['gnashrc', '.gnashrc', 'gnashpluginrc', '.gnashpluginrc'], \ 'gnuplot': ['file.gpi', '.gnuplot'], diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim index eb367cfe5c..9a31f61582 100644 --- a/src/nvim/testdir/test_popup.vim +++ b/src/nvim/testdir/test_popup.vim @@ -325,6 +325,21 @@ func Test_compl_vim_cmds_after_register_expr() bwipe! endfunc +func Test_compl_ignore_mappings() + call setline(1, ['foo', 'bar', 'baz', 'foobar']) + inoremap <C-P> (C-P) + inoremap <C-N> (C-N) + normal! G + call feedkeys("o\<C-X>\<C-N>\<C-N>\<C-N>\<C-P>\<C-N>\<C-Y>", 'tx') + call assert_equal('baz', getline('.')) + " Also test with unsimplified keys + call feedkeys("o\<C-X>\<*C-N>\<*C-N>\<*C-N>\<*C-P>\<*C-N>\<C-Y>", 'tx') + call assert_equal('baz', getline('.')) + iunmap <C-P> + iunmap <C-N> + bwipe! +endfunc + func DummyCompleteOne(findstart, base) if a:findstart return 0 |