From 7aec10838ec4efe1dbc864e41a2b8c4feca6f197 Mon Sep 17 00:00:00 2001 From: abeldekat <58370433+abeldekat@users.noreply.github.com> Date: Wed, 6 May 2026 10:43:22 +0200 Subject: [PATCH] fix(animate): react to Nightly triggering `WinScrolled` on `incsearch` Details: - See PR 39308 in neovim/neovim Related to #234 --- lua/mini/animate.lua | 4 +++- ...imates-result-of-'incsearch'-on-nvim-=0.13 | 23 ++++++++++++++++++ ...es-result-of-'incsearch'-on-nvim-=0.13-002 | 23 ++++++++++++++++++ ...es-result-of-'incsearch'-on-nvim-=0.13-003 | 23 ++++++++++++++++++ ...es-result-of-'incsearch'-on-nvim-=0.13-004 | 23 ++++++++++++++++++ tests/test_animate.lua | 24 +++++++++++++++++++ 6 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 tests/screenshots/tests-test_animate.lua---Scroll---automatically-animates-result-of-'incsearch'-on-nvim-=0.13 create mode 100644 tests/screenshots/tests-test_animate.lua---Scroll---automatically-animates-result-of-'incsearch'-on-nvim-=0.13-002 create mode 100644 tests/screenshots/tests-test_animate.lua---Scroll---automatically-animates-result-of-'incsearch'-on-nvim-=0.13-003 create mode 100644 tests/screenshots/tests-test_animate.lua---Scroll---automatically-animates-result-of-'incsearch'-on-nvim-=0.13-004 diff --git a/lua/mini/animate.lua b/lua/mini/animate.lua index bb0b891fd..d48501408 100644 --- a/lua/mini/animate.lua +++ b/lua/mini/animate.lua @@ -1266,7 +1266,9 @@ H.create_autocommands = function() -- end). Use `vim.schedule()` to make it affect state only after scroll is -- done and cursor is already in correct final position. au('CursorMoved', '*', vim.schedule_wrap(H.track_scroll_state_partial), 'Track partial scroll state') - au('CmdlineLeave', '*', H.on_cmdline_leave, 'On CmdlineLeave') + + -- TODO: Remove after Neovim=0.12 support is dropped + if vim.fn.has('nvim-0.13') == 0 then au('CmdlineLeave', '*', H.on_cmdline_leave, 'On CmdlineLeave') end -- Use `vim.schedule_wrap()` animation to get a window data used for -- displaying (and not one after just opening). Useful for 'nvim-tree'. diff --git a/tests/screenshots/tests-test_animate.lua---Scroll---automatically-animates-result-of-'incsearch'-on-nvim-=0.13 b/tests/screenshots/tests-test_animate.lua---Scroll---automatically-animates-result-of-'incsearch'-on-nvim-=0.13 new file mode 100644 index 000000000..2389e0cfd --- /dev/null +++ b/tests/screenshots/tests-test_animate.lua---Scroll---automatically-animates-result-of-'incsearch'-on-nvim-=0.13 @@ -0,0 +1,23 @@ +--|---------|---------|----- +01|hhhh +02|iiii +03|jjjj +04|kkkk +05|llll +06|mmmm +07|nnnn +08|oooo +09|[No Name] 15,1 +10|/oo ...[1/2] + +--|---------|---------|----- +01|0000000000000000000000000 +02|0000000000000000000000000 +03|0000000000000000000000000 +04|0000000000000000000000000 +05|0000000000000000000000000 +06|0000000000000000000000000 +07|0000000000000000000000000 +08|1122000000000000000000000 +09|3333333333333333333333333 +10|4444444444444444444444444 diff --git a/tests/screenshots/tests-test_animate.lua---Scroll---automatically-animates-result-of-'incsearch'-on-nvim-=0.13-002 b/tests/screenshots/tests-test_animate.lua---Scroll---automatically-animates-result-of-'incsearch'-on-nvim-=0.13-002 new file mode 100644 index 000000000..16c31fea4 --- /dev/null +++ b/tests/screenshots/tests-test_animate.lua---Scroll---automatically-animates-result-of-'incsearch'-on-nvim-=0.13-002 @@ -0,0 +1,23 @@ +--|---------|---------|----- +01|iiii +02|jjjj +03|kkkk +04|llll +05|mmmm +06|nnnn +07|oooo +08|~ +09|[No Name] 9,1 +10|/oo ...[1/2] + +--|---------|---------|----- +01|0000000000000000000000000 +02|0000000000000000000000000 +03|0000000000000000000000000 +04|0000000000000000000000000 +05|0000000000000000000000000 +06|0000000000000000000000000 +07|1111000000000000000000000 +08|2222222222222222222222222 +09|3333333333333333333333333 +10|4444444444444444444444444 diff --git a/tests/screenshots/tests-test_animate.lua---Scroll---automatically-animates-result-of-'incsearch'-on-nvim-=0.13-003 b/tests/screenshots/tests-test_animate.lua---Scroll---automatically-animates-result-of-'incsearch'-on-nvim-=0.13-003 new file mode 100644 index 000000000..5db463375 --- /dev/null +++ b/tests/screenshots/tests-test_animate.lua---Scroll---automatically-animates-result-of-'incsearch'-on-nvim-=0.13-003 @@ -0,0 +1,23 @@ +--|---------|---------|----- +01|aaaa +02|bbbb +03|cccc +04|dddd +05|eeee +06|ffff +07|gggg +08|hhhh +09|[No Name] 1,3 +10|?aa ...[2/2] + +--|---------|---------|----- +01|0011222222222222222222222 +02|2222222222222222222222222 +03|2222222222222222222222222 +04|2222222222222222222222222 +05|2222222222222222222222222 +06|2222222222222222222222222 +07|2222222222222222222222222 +08|2222222222222222222222222 +09|3333333333333333333333333 +10|4444444444444444444444444 diff --git a/tests/screenshots/tests-test_animate.lua---Scroll---automatically-animates-result-of-'incsearch'-on-nvim-=0.13-004 b/tests/screenshots/tests-test_animate.lua---Scroll---automatically-animates-result-of-'incsearch'-on-nvim-=0.13-004 new file mode 100644 index 000000000..da19bde58 --- /dev/null +++ b/tests/screenshots/tests-test_animate.lua---Scroll---automatically-animates-result-of-'incsearch'-on-nvim-=0.13-004 @@ -0,0 +1,23 @@ +--|---------|---------|----- +01|aaaa +02|bbbb +03|cccc +04|dddd +05|eeee +06|ffff +07|gggg +08|hhhh +09|[No Name] 8,2 +10|?aa ...[2/2] + +--|---------|---------|----- +01|0000111111111111111111111 +02|1111111111111111111111111 +03|1111111111111111111111111 +04|1111111111111111111111111 +05|1111111111111111111111111 +06|1111111111111111111111111 +07|1111111111111111111111111 +08|1111111111111111111111111 +09|2222222222222222222222222 +10|3333333333333333333333333 diff --git a/tests/test_animate.lua b/tests/test_animate.lua index 8f87e0707..890df87ad 100644 --- a/tests/test_animate.lua +++ b/tests/test_animate.lua @@ -1850,6 +1850,8 @@ T['Scroll']['does not automatically animate after buffer change'] = function() end T['Scroll']["does not automatically animate result of 'incsearch'"] = function() + if child.fn.has('nvim-0.13') == 1 then return end + child.o.incsearch = true child.set_size(10, 25) @@ -1869,6 +1871,28 @@ T['Scroll']["does not automatically animate result of 'incsearch'"] = function() child.expect_screenshot() end +T['Scroll']["automatically animates result of 'incsearch' on nvim>=0.13"] = function() + if child.fn.has('nvim-0.13') == 0 then return end + + child.o.incsearch = true + + child.set_size(10, 25) + + -- Should work for search with `/` + type_keys('/', 'oo', '') + child.expect_screenshot() + sleep(step_time + small_time) + -- Should start animation + child.expect_screenshot() + + -- Should work for search with `?` + type_keys('?', 'aa', '') + child.expect_screenshot() + sleep(step_time + small_time) + -- Should start animation + child.expect_screenshot() +end + T['Scroll']['does not animate in Select mode'] = function() child.set_size(5, 15) child.cmd('smap call winrestview({ "topline": 3 })')