vim-patch:8.2.2045: highlighting a character too much with incsearch

Problem:    Highlighting a character too much with incsearch.
Solution:   Check "search_match_endcol". (Christian Brabandt, closes vim/vim#7360)
448465e687
This commit is contained in:
Jan Edmund Lazo
2021-03-26 19:42:00 -04:00
parent 31e2546cc9
commit 618b17f575
2 changed files with 38 additions and 1 deletions

View File

@@ -2322,7 +2322,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
getvcol(curwin, &pos, (colnr_T *)&tocol, NULL, NULL);
}
// do at least one character; happens when past end of line
if (fromcol == tocol) {
if (fromcol == tocol && search_match_endcol) {
tocol = fromcol + 1;
}
area_highlighting = true;

View File

@@ -2,6 +2,7 @@
source shared.vim
source screendump.vim
source check.vim
func Test_search_cmdline()
" See test/functional/legacy/search_spec.lua
@@ -1192,4 +1193,40 @@ func Test_search_smartcase_utf8()
close!
endfunc
func Test_zzzz_incsearch_highlighting_newline()
CheckRunVimInTerminal
CheckOption incsearch
CheckScreendump
new
call test_override("char_avail", 1)
let commands =<< trim [CODE]
set incsearch nohls
call setline(1, ['test', 'xxx'])
[CODE]
call writefile(commands, 'Xincsearch_nl')
let buf = RunVimInTerminal('-S Xincsearch_nl', {'rows': 5, 'cols': 10})
" Need to send one key at a time to force a redraw
call term_sendkeys(buf, '/test')
sleep 100m
call VerifyScreenDump(buf, 'Test_incsearch_newline1', {})
call term_sendkeys(buf, '\n')
sleep 100m
call VerifyScreenDump(buf, 'Test_incsearch_newline2', {})
call term_sendkeys(buf, 'x')
sleep 100m
call VerifyScreenDump(buf, 'Test_incsearch_newline3', {})
call term_sendkeys(buf, 'x')
call VerifyScreenDump(buf, 'Test_incsearch_newline4', {})
call term_sendkeys(buf, "\<CR>")
sleep 100m
call VerifyScreenDump(buf, 'Test_incsearch_newline5', {})
call StopVimInTerminal(buf)
" clean up
call delete('Xincsearch_nl')
call test_override("char_avail", 0)
bw
endfunc
" vim: shiftwidth=2 sts=2 expandtab