diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index 2be06a359b..3a309ae149 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -568,11 +568,6 @@ bool check_compl_option(bool dict_opt) bool vim_is_ctrl_x_key(int c) FUNC_ATTR_WARN_UNUSED_RESULT { - // Always allow ^R - let its results then be checked - if (c == Ctrl_R && ctrl_x_mode != CTRL_X_REGISTER) { - return true; - } - // Accept and if the popup menu is visible. if (ins_compl_pum_key(c)) { return true; @@ -2804,7 +2799,7 @@ bool ins_compl_prep(int c) retval = set_ctrl_x_mode(c); } else if (ctrl_x_mode_not_default()) { // We're already in CTRL-X mode, do we stay in it? - if (!vim_is_ctrl_x_key(c)) { + if (c != Ctrl_R && !vim_is_ctrl_x_key(c)) { ctrl_x_mode = ctrl_x_mode_scroll() ? CTRL_X_NORMAL : CTRL_X_FINISHED; edit_submode = NULL; } @@ -2834,7 +2829,7 @@ bool ins_compl_prep(int c) // reset continue_* if we left expansion-mode, if we stay they'll be // (re)set properly in ins_complete() - if (!vim_is_ctrl_x_key(c)) { + if (c != Ctrl_R && !vim_is_ctrl_x_key(c)) { compl_cont_status = 0; compl_cont_mode = 0; } diff --git a/test/old/testdir/test_ins_complete.vim b/test/old/testdir/test_ins_complete.vim index 4a48148227..0c12381cad 100644 --- a/test/old/testdir/test_ins_complete.vim +++ b/test/old/testdir/test_ins_complete.vim @@ -6418,4 +6418,24 @@ func Test_autocomplete_with_auto_format() call Ntest_override("char_avail", 0) endfunc +func Test_completion_with_mapped_ctrl_r() + new + let b:n = 0 + let @a = 'AABBCCDDEE' + " Ctrl-R mapping is triggered + inoremap let b:n += 1 + inoremap call complete(col('.'), []) + call feedkeys("i\\<*C-R>abcde\", 'tx') + call assert_equal(1, b:n) + call assert_equal('abcde', getline('.')) + + " Ctrl-X Ctrl-R still works with Ctrl-R mapped + call feedkeys("ccAAB\<*C-X>\<*C-R>\<*C-Y>\", 'tx') + call assert_equal(1, b:n) + call assert_equal('AABBCCDDEE', getline('.')) + + let @a = '' + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab nofoldenable