mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 14:38:32 +00:00
fix(inccommand): avoid unnecessary redraw when not showing (#20244)
This commit is contained in:
@@ -2385,6 +2385,7 @@ static int command_line_changed(CommandLineState *s)
|
|||||||
// Trigger CmdlineChanged autocommands.
|
// Trigger CmdlineChanged autocommands.
|
||||||
do_autocmd_cmdlinechanged(s->firstc > 0 ? s->firstc : '-');
|
do_autocmd_cmdlinechanged(s->firstc > 0 ? s->firstc : '-');
|
||||||
|
|
||||||
|
const bool prev_cmdpreview = cmdpreview;
|
||||||
if (s->firstc == ':'
|
if (s->firstc == ':'
|
||||||
&& current_sctx.sc_sid == 0 // only if interactive
|
&& current_sctx.sc_sid == 0 // only if interactive
|
||||||
&& *p_icm != NUL // 'inccommand' is set
|
&& *p_icm != NUL // 'inccommand' is set
|
||||||
@@ -2393,10 +2394,11 @@ static int command_line_changed(CommandLineState *s)
|
|||||||
&& !vpeekc_any()
|
&& !vpeekc_any()
|
||||||
&& cmdpreview_may_show(s)) {
|
&& cmdpreview_may_show(s)) {
|
||||||
// 'inccommand' preview has been shown.
|
// 'inccommand' preview has been shown.
|
||||||
} else if (cmdpreview) {
|
|
||||||
cmdpreview = false;
|
|
||||||
update_screen(UPD_SOME_VALID); // Clear 'inccommand' preview.
|
|
||||||
} else {
|
} else {
|
||||||
|
cmdpreview = false;
|
||||||
|
if (prev_cmdpreview) {
|
||||||
|
update_screen(UPD_SOME_VALID); // Clear 'inccommand' preview.
|
||||||
|
}
|
||||||
if (s->xpc.xp_context == EXPAND_NOTHING && (KeyTyped || vpeekc() == NUL)) {
|
if (s->xpc.xp_context == EXPAND_NOTHING && (KeyTyped || vpeekc() == NUL)) {
|
||||||
may_do_incsearch_highlighting(s->firstc, s->count, &s->is_state);
|
may_do_incsearch_highlighting(s->firstc, s->count, &s->is_state);
|
||||||
}
|
}
|
||||||
|
@@ -1190,6 +1190,8 @@ describe(":substitute, inccommand=split", function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it("deactivates if 'redrawtime' is exceeded #5602", function()
|
it("deactivates if 'redrawtime' is exceeded #5602", function()
|
||||||
|
-- prevent redraws from 'incsearch'
|
||||||
|
meths.set_option('incsearch', false)
|
||||||
-- Assert that 'inccommand' is ENABLED initially.
|
-- Assert that 'inccommand' is ENABLED initially.
|
||||||
eq("split", eval("&inccommand"))
|
eq("split", eval("&inccommand"))
|
||||||
-- Set 'redrawtime' to minimal value, to ensure timeout is triggered.
|
-- Set 'redrawtime' to minimal value, to ensure timeout is triggered.
|
||||||
@@ -2972,6 +2974,59 @@ it(':substitute with inccommand, does not crash if range contains invalid marks'
|
|||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it(':substitute with inccommand, no unnecessary redraw if preview is not shown', function()
|
||||||
|
local screen = Screen.new(60, 6)
|
||||||
|
clear()
|
||||||
|
common_setup(screen, 'split', 'test')
|
||||||
|
feed(':ls<CR>')
|
||||||
|
screen:expect([[
|
||||||
|
test |
|
||||||
|
{15:~ }|
|
||||||
|
{11: }|
|
||||||
|
:ls |
|
||||||
|
1 %a + "[No Name]" line 1 |
|
||||||
|
{13:Press ENTER or type command to continue}^ |
|
||||||
|
]])
|
||||||
|
feed(':s')
|
||||||
|
-- no unnecessary redraw, so messages are still shown
|
||||||
|
screen:expect([[
|
||||||
|
test |
|
||||||
|
{15:~ }|
|
||||||
|
{11: }|
|
||||||
|
:ls |
|
||||||
|
1 %a + "[No Name]" line 1 |
|
||||||
|
:s^ |
|
||||||
|
]])
|
||||||
|
feed('o')
|
||||||
|
screen:expect([[
|
||||||
|
test |
|
||||||
|
{15:~ }|
|
||||||
|
{11: }|
|
||||||
|
:ls |
|
||||||
|
1 %a + "[No Name]" line 1 |
|
||||||
|
:so^ |
|
||||||
|
]])
|
||||||
|
feed('<BS>')
|
||||||
|
screen:expect([[
|
||||||
|
test |
|
||||||
|
{15:~ }|
|
||||||
|
{11: }|
|
||||||
|
:ls |
|
||||||
|
1 %a + "[No Name]" line 1 |
|
||||||
|
:s^ |
|
||||||
|
]])
|
||||||
|
feed('/test')
|
||||||
|
-- now inccommand is shown, so screen is redrawn
|
||||||
|
screen:expect([[
|
||||||
|
{12:test} |
|
||||||
|
{15:~ }|
|
||||||
|
{15:~ }|
|
||||||
|
{15:~ }|
|
||||||
|
{15:~ }|
|
||||||
|
:s/test^ |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
it(":substitute doesn't crash with inccommand, if undo is empty #12932", function()
|
it(":substitute doesn't crash with inccommand, if undo is empty #12932", function()
|
||||||
local screen = Screen.new(10,5)
|
local screen = Screen.new(10,5)
|
||||||
clear()
|
clear()
|
||||||
|
Reference in New Issue
Block a user