aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-06-11 13:04:19 +0800
committerGitHub <noreply@github.com>2022-06-11 13:04:19 +0800
commit2b539d6fdf985d765ce03964be320c69d02b376c (patch)
tree8a2e50e33be1e1936b47b9b5fc59c7c6f7115642
parent2b252430aa9ef52de7da733e2c0221c97111bce2 (diff)
downloadrneovim-2b539d6fdf985d765ce03964be320c69d02b376c.tar.gz
rneovim-2b539d6fdf985d765ce03964be320c69d02b376c.tar.bz2
rneovim-2b539d6fdf985d765ce03964be320c69d02b376c.zip
fix(inccommand): clear cmdpreview state if preview is not shown (#18923)
-rw-r--r--src/nvim/ex_getln.c1
-rw-r--r--test/functional/ui/inccommand_spec.lua30
2 files changed, 31 insertions, 0 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index ad3ccf2a99..5bca6b5f81 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -2516,6 +2516,7 @@ static void cmdpreview_show(CommandLineState *s)
// If preview callback returned 0, update screen to clear remnants of an earlier preview.
if (cmdpreview_type == 0) {
+ cmdpreview = false;
update_screen(SOME_VALID);
}
end:
diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua
index a95cb0e83a..b01504db4f 100644
--- a/test/functional/ui/inccommand_spec.lua
+++ b/test/functional/ui/inccommand_spec.lua
@@ -2907,6 +2907,36 @@ it(':substitute with inccommand, timer-induced :redraw #9777', function()
]])
end)
+it(':substitute with inccommand, allows :redraw before first separator is typed #18857', function()
+ local screen = Screen.new(30,6)
+ clear()
+ common_setup(screen, 'split', 'foo bar baz\nbar baz fox\nbar foo baz')
+ command('hi! link NormalFloat CursorLine')
+ local float_buf = meths.create_buf(false, true)
+ meths.open_win(float_buf, false, {
+ relative = 'editor', height = 1, width = 5, row = 3, col = 0, focusable = false,
+ })
+ feed(':%s')
+ screen:expect([[
+ foo bar baz |
+ bar baz fox |
+ bar foo baz |
+ {16: }{15: }|
+ {15:~ }|
+ :%s^ |
+ ]])
+ meths.buf_set_lines(float_buf, 0, -1, true, {'foo'})
+ command('redraw')
+ screen:expect([[
+ foo bar baz |
+ bar baz fox |
+ bar foo baz |
+ {16:foo }{15: }|
+ {15:~ }|
+ :%s^ |
+ ]])
+end)
+
it(":substitute doesn't crash with inccommand, if undo is empty #12932", function()
local screen = Screen.new(10,5)
clear()