Skip to content

Commit c72d877

Browse files
authored
fix(cmdline): wrong 'incsearch' highlighting after :redraw (neovim#27947)
Problem: Calling :redraw from a timer callback clears 'incsearch' highlighting. Solution: Re-apply 'incsearch' highlighting if the screen was updated.
1 parent 7549845 commit c72d877

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Diff for: src/nvim/ex_getln.c

+5
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,7 @@ static int command_line_execute(VimState *state, int key)
11671167
return -1; // get another key
11681168
}
11691169

1170+
disptick_T display_tick_saved = display_tick;
11701171
CommandLineState *s = (CommandLineState *)state;
11711172
s->c = key;
11721173

@@ -1178,6 +1179,10 @@ static int command_line_execute(VimState *state, int key)
11781179
} else {
11791180
map_execute_lua(false);
11801181
}
1182+
// Re-apply 'incsearch' highlighting in case it was cleared.
1183+
if (display_tick > display_tick_saved && s->is_state.did_incsearch) {
1184+
may_do_incsearch_highlighting(s->firstc, s->count, &s->is_state);
1185+
}
11811186

11821187
// nvim_select_popupmenu_item() can be called from the handling of
11831188
// K_EVENT, K_COMMAND, or K_LUA.

Diff for: test/functional/ui/searchhl_spec.lua

+14
Original file line numberDiff line numberDiff line change
@@ -674,4 +674,18 @@ describe('search highlighting', function()
674674
:%g@a/b^ |
675675
]])
676676
end)
677+
678+
it('incsearch is still visible after :redraw from K_EVENT', function()
679+
fn.setline(1, { 'foo', 'bar' })
680+
feed('/foo<CR>/bar')
681+
screen:expect([[
682+
foo |
683+
{3:bar} |
684+
{1:~ }|*4
685+
/bar^ |
686+
]])
687+
command('redraw!')
688+
-- There is an intermediate state where :redraw! removes 'incsearch' highlight.
689+
screen:expect_unchanged(true)
690+
end)
677691
end)

0 commit comments

Comments
 (0)