mirror of
https://github.com/folke/snacks.nvim
synced 2025-12-23 08:47:57 +00:00
fix(scroll): stop anim and reset state when win has new buf, or buf was changed. Closes #1820. Closes #2221
This commit is contained in:
parent
79f3a8d8b3
commit
766f7b87aa
1 changed files with 2 additions and 5 deletions
|
|
@ -87,13 +87,10 @@ local function get_state(win)
|
|||
local changedtick = vim.api.nvim_buf_get_changedtick(buf)
|
||||
local view = vim.api.nvim_win_call(win, vim.fn.winsaveview) ---@type vim.fn.winsaveview.ret
|
||||
if not (states[win] and states[win].buf == buf and states[win].changedtick == changedtick) then
|
||||
-- go to target if we're still animating and resetting due to a change
|
||||
if states[win] and states[win].anim and not states[win].anim.done and states[win].buf == buf then
|
||||
-- new buffer, or buffer changed: cancel existing animation and reset state
|
||||
if states[win] and states[win].anim then
|
||||
states[win].anim:stop()
|
||||
states[win].anim = nil
|
||||
vim.api.nvim_win_call(win, function()
|
||||
vim.fn.winrestview(states[win].target)
|
||||
end)
|
||||
wo(win) -- restore window options
|
||||
end
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue