diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-09-13 01:52:24 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-09-13 08:25:20 -0400 |
commit | 25992df761f24546df69aa01fd03d0ae96e96fbe (patch) | |
tree | 12261c37710b715c0b7e3f1f548677dbc0ea61f0 | |
parent | 476c50903a38a2ab85546c6f061117950d6e79fc (diff) | |
download | rneovim-25992df761f24546df69aa01fd03d0ae96e96fbe.tar.gz rneovim-25992df761f24546df69aa01fd03d0ae96e96fbe.tar.bz2 rneovim-25992df761f24546df69aa01fd03d0ae96e96fbe.zip |
vim-patch:8.1.1148: CTRL-L with 'incsearch' does not pick up char under cursor
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 vim/vim#3620)
https://github.com/vim/vim/commit/730f48fe3691dc62331f3df23cb947bfc33a5add
-rw-r--r-- | src/nvim/ex_getln.c | 21 | ||||
-rw-r--r-- | src/nvim/testdir/test_search.vim | 18 |
2 files changed, 28 insertions, 11 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index fe52a6cfa7..68d4c57c65 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -567,6 +567,7 @@ static void may_do_incsearch_highlighting(int firstc, long count, // May set "*c" to the added character. // Return OK when calling command_line_not_changed. static int may_add_char_to_search(int firstc, int *c, incsearch_state_T *s) + FUNC_ATTR_NONNULL_ALL { int skiplen, patlen; @@ -583,8 +584,8 @@ static int may_add_char_to_search(int firstc, int *c, incsearch_state_T *s) if (s->did_incsearch) { curwin->w_cursor = s->match_end; - if (!equalpos(curwin->w_cursor, s->search_start)) { - *c = gchar_cursor(); + *c = gchar_cursor(); + if (*c != NUL) { // If 'ignorecase' and 'smartcase' are set and the // command line has no uppercase characters, convert // the character to lowercase @@ -592,16 +593,14 @@ static int may_add_char_to_search(int firstc, int *c, incsearch_state_T *s) && !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 = '\\'; - } - return FAIL; + if (*c == firstc + || vim_strchr((char_u *)(p_magic ? "\\~^$.*[" : "\\^$"), *c) + != NULL) { + // put a backslash before special characters + stuffcharReadbuff(*c); + *c = '\\'; } + return FAIL; } } return OK; diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index a945304e78..01580d756c 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -1068,6 +1068,24 @@ func Test_one_error_msg() call assert_fails('call search(" \\((\\v[[=P=]]){185}+ ")', 'E871:') endfunc +func Test_incsearch_add_char_under_cursor() + throw 'skipped: Nvim does not support test_override()' + 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 + " Test for the search() function with match at the cursor position func Test_search_match_at_curpos() new |