mirror of
https://github.com/folke/snacks.nvim
synced 2025-12-23 08:47:57 +00:00
fix(scroll): stop animations when buf/changedtick changes
This commit is contained in:
parent
1f2b8b765e
commit
a42b3761f7
1 changed files with 11 additions and 0 deletions
|
|
@ -302,11 +302,22 @@ function M.check(win)
|
|||
or (state.target.topline == state.current.topline and state.target.topfill < state.current.topfill)
|
||||
|
||||
local scrolled = 0
|
||||
local changedtick = state.changedtick
|
||||
local buf = vim.api.nvim_win_get_buf(win)
|
||||
|
||||
state.anim = Snacks.animate(0, scrolls, function(value, ctx)
|
||||
if not vim.api.nvim_win_is_valid(win) then
|
||||
return
|
||||
end
|
||||
|
||||
if not vim.api.nvim_buf_is_valid(buf) or buf ~= vim.api.nvim_win_get_buf(win) then
|
||||
return
|
||||
end
|
||||
|
||||
if vim.b[state.buf].changedtick ~= changedtick then
|
||||
return
|
||||
end
|
||||
|
||||
vim.api.nvim_win_call(win, function()
|
||||
if ctx.done then
|
||||
vim.fn.winrestview(state.target)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue