]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0373: Ctrl-R mapping not triggered during completion v9.2.0373
authorzeertzjq <zeertzjq@outlook.com>
Mon, 20 Apr 2026 15:43:56 +0000 (15:43 +0000)
committerChristian Brabandt <cb@256bit.org>
Mon, 20 Apr 2026 15:46:08 +0000 (15:46 +0000)
Problem:  Ctrl-R mapping not triggered during completion.
Solution: Move Ctrl-R check out of vim_is_ctrl_x_key()
          (zeertzjq).

fixes:  #20004
closes: #20006

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/insexpand.c
src/testdir/test_ins_complete.vim
src/version.c

index 7545e9b4eccc37472379fe4c41288c62949b61fe..019557cab779d6de9bb1c4c5637a14900bc61a8e 100644 (file)
@@ -494,10 +494,6 @@ has_compl_option(int dict_opt)
     int
 vim_is_ctrl_x_key(int c)
 {
-    // Always allow ^R - let its results then be checked
-    if (c == Ctrl_R && ctrl_x_mode != CTRL_X_REGISTER)
-       return TRUE;
-
     // Accept <PageUp> and <PageDown> if the popup menu is visible.
     if (ins_compl_pum_key(c))
        return TRUE;
@@ -3155,7 +3151,7 @@ ins_compl_prep(int 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;
@@ -3183,7 +3179,7 @@ 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;
index a32bc45ccabe4926a0e388452e4c46b69beb43aa..ac1b5678ce74840315d7741014d6128d20bbd72d 100644 (file)
@@ -6305,4 +6305,24 @@ func Test_autocomplete_with_auto_format()
   call test_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 <buffer> <C-R> <Cmd>let b:n += 1<CR>
+  inoremap <buffer> <F2> <Cmd>call complete(col('.'), [])<CR>
+  call feedkeys("i\<F2>\<*C-R>abcde\<Esc>", '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>\<Esc>", 'tx')
+  call assert_equal(1, b:n)
+  call assert_equal('AABBCCDDEE', getline('.'))
+
+  let @a = ''
+  bwipe!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab nofoldenable
index 54ea03e260b668fab55455b7ed545f2569ec70fb..1328b4db3849565de1610087b456fb76144b583f 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    373,
 /**/
     372,
 /**/