mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
vim-patch:8.2.3940: match highlight disappears when doing incsearch for ":s/pat"
Problem: Match highlight disappears when doing incsearch for ":s/pat".
Solution: Only use line limit for incsearch highlighting. (closes vim/vim#9425)
94fb8274ca
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -425,7 +425,7 @@ static void next_search_hl(win_T *win, match_T *search_hl, match_T *shl, linenr_
|
|||||||
const int called_emsg_before = called_emsg;
|
const int called_emsg_before = called_emsg;
|
||||||
|
|
||||||
// for :{range}s/pat only highlight inside the range
|
// for :{range}s/pat only highlight inside the range
|
||||||
if (lnum < search_first_line || lnum > search_last_line) {
|
if ((lnum < search_first_line || lnum > search_last_line) && cur == NULL) {
|
||||||
shl->lnum = 0;
|
shl->lnum = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -380,6 +380,27 @@ func Test_match_in_linebreak()
|
|||||||
call delete('XscriptMatchLinebreak')
|
call delete('XscriptMatchLinebreak')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_match_with_incsearch()
|
||||||
|
CheckRunVimInTerminal
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
set incsearch
|
||||||
|
call setline(1, range(20))
|
||||||
|
call matchaddpos('ErrorMsg', [3])
|
||||||
|
END
|
||||||
|
call writefile(lines, 'XmatchWithIncsearch')
|
||||||
|
let buf = RunVimInTerminal('-S XmatchWithIncsearch', #{rows: 6})
|
||||||
|
call TermWait(buf)
|
||||||
|
call VerifyScreenDump(buf, 'Test_match_with_incsearch_1', {})
|
||||||
|
|
||||||
|
call term_sendkeys(buf, ":s/0")
|
||||||
|
call VerifyScreenDump(buf, 'Test_match_with_incsearch_2', {})
|
||||||
|
|
||||||
|
call term_sendkeys(buf, "\<CR>")
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
call delete('XmatchWithIncsearch')
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Test for deleting matches outside of the screen redraw top/bottom lines
|
" Test for deleting matches outside of the screen redraw top/bottom lines
|
||||||
" This should cause a redraw of those lines.
|
" This should cause a redraw of those lines.
|
||||||
func Test_matchdelete_redraw()
|
func Test_matchdelete_redraw()
|
||||||
|
@@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')(after_each)
|
|||||||
local Screen = require('test.functional.ui.screen')
|
local Screen = require('test.functional.ui.screen')
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
local exec = helpers.exec
|
local exec = helpers.exec
|
||||||
|
local feed = helpers.feed
|
||||||
|
|
||||||
before_each(clear)
|
before_each(clear)
|
||||||
|
|
||||||
@@ -64,4 +65,36 @@ describe('match highlighting', function()
|
|||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('is shown with incsearch vim-patch:8.2.3940', function()
|
||||||
|
local screen = Screen.new(75, 6)
|
||||||
|
screen:set_default_attr_ids({
|
||||||
|
[0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
|
||||||
|
[1] = {background = Screen.colors.Yellow}, -- Search
|
||||||
|
[2] = {background = Screen.colors.Red, foreground = Screen.colors.White}, -- ErrorMsg
|
||||||
|
})
|
||||||
|
screen:attach()
|
||||||
|
exec([[
|
||||||
|
set incsearch
|
||||||
|
call setline(1, range(20))
|
||||||
|
call matchaddpos('ErrorMsg', [3])
|
||||||
|
]])
|
||||||
|
screen:expect([[
|
||||||
|
^0 |
|
||||||
|
1 |
|
||||||
|
{2:2} |
|
||||||
|
3 |
|
||||||
|
4 |
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
feed(':s/0')
|
||||||
|
screen:expect([[
|
||||||
|
{1:0} |
|
||||||
|
1 |
|
||||||
|
{2:2} |
|
||||||
|
3 |
|
||||||
|
4 |
|
||||||
|
:s/0^ |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user