]> granicus.if.org Git - vim/commitdiff
patch 8.1.1148: CTRL-L with 'incsearch' does not pick up char under cursor v8.1.1148
authorBram Moolenaar <Bram@vim.org>
Thu, 11 Apr 2019 11:45:57 +0000 (13:45 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 11 Apr 2019 11:45:57 +0000 (13:45 +0200)
Problem:    CTRL-L with 'incsearch' does not pick up char under cursor.
            (Smylers)
Solution:   Do not compare the position with the cursor position. (Hirohito
            Higashi, closes #3620)

src/ex_getln.c
src/testdir/test_search.vim
src/version.c

index 52eda33c736daac1ac29bcc584222bfd31c0c168..e6bb815b45ab8cdaa06bbb34abaab792d6a26670 100644 (file)
@@ -745,39 +745,35 @@ may_add_char_to_search(int firstc, int *c, incsearch_state_T *is_state)
     if (is_state->did_incsearch)
     {
        curwin->w_cursor = is_state->match_end;
-       if (!EQUAL_POS(curwin->w_cursor, is_state->search_start))
+       *c = gchar_cursor();
+       if (*c != NUL)
        {
-           *c = gchar_cursor();
-
            // If 'ignorecase' and 'smartcase' are set and the
            // command line has no uppercase characters, convert
            // the character to lowercase.
            if (p_ic && p_scs && !pat_has_uppercase(ccline.cmdbuff + skiplen))
                *c = MB_TOLOWER(*c);
-           if (*c != NUL)
+           if (*c == firstc || vim_strchr((char_u *)(
+                              p_magic ? "\\~^$.*[" : "\\^$"), *c) != NULL)
+           {
+               // put a backslash before special characters
+               stuffcharReadbuff(*c);
+               *c = '\\';
+           }
+           // add any composing characters
+           if (mb_char2len(*c) != mb_ptr2len(ml_get_cursor()))
            {
-               if (*c == firstc || vim_strchr((char_u *)(
-                                  p_magic ? "\\~^$.*[" : "\\^$"), *c) != NULL)
+               int save_c = *c;
+
+               while (mb_char2len(*c) != mb_ptr2len(ml_get_cursor()))
                {
-                   // put a backslash before special characters
+                   curwin->w_cursor.col += mb_char2len(*c);
+                   *c = gchar_cursor();
                    stuffcharReadbuff(*c);
-                   *c = '\\';
                }
-               // add any composing characters
-               if (mb_char2len(*c) != mb_ptr2len(ml_get_cursor()))
-               {
-                   int save_c = *c;
-
-                   while (mb_char2len(*c) != mb_ptr2len(ml_get_cursor()))
-                   {
-                       curwin->w_cursor.col += mb_char2len(*c);
-                       *c = gchar_cursor();
-                       stuffcharReadbuff(*c);
-                   }
-                   *c = save_c;
-               }
-               return FAIL;
+               *c = save_c;
            }
+           return FAIL;
        }
     }
     return OK;
index d32369d5a23cc82645132332ec14350ae5062147..525d0d200d314ce18006acc3a94e67aacdd9d265 100644 (file)
@@ -1248,3 +1248,20 @@ func Test_one_error_msg()
   " This  was also giving an internal error
   call assert_fails('call search(" \\((\\v[[=P=]]){185}+             ")', 'E871:')
 endfunc
+
+func Test_incsearch_add_char_under_cursor()
+  if !exists('+incsearch')
+    return
+  endif
+  set incsearch
+  new
+  call setline(1, ['find match', 'anything'])
+  1
+  call test_override('char_avail', 1)
+  call feedkeys("fc/m\<C-L>\<C-L>\<C-L>\<C-L>\<C-L>\<CR>", 'tx')
+  call assert_equal('match', @/)
+  call test_override('char_avail', 0)
+
+  set incsearch&
+  bwipe!
+endfunc
index 47553177954ecc6c1404dc4e209a99b8c8557190..3da2d7a0973b410b6e491763b64b9c6d641a09d4 100644 (file)
@@ -771,6 +771,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1148,
 /**/
     1147,
 /**/