fix(ui): save/restore view right before/after rendering

This commit is contained in:
Folke Lemaitre 2024-06-29 13:58:13 +02:00
parent a75d950b8f
commit 5d334b9f57
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
2 changed files with 10 additions and 6 deletions

View File

@ -147,13 +147,7 @@ end
function M:update()
if self.buf and vim.api.nvim_buf_is_valid(self.buf) then
vim.bo[self.buf].modifiable = true
local view = vim.api.nvim_win_call(self.view.win, vim.fn.winsaveview)
self.render:update()
vim.api.nvim_win_call(self.view.win, function()
vim.fn.winrestview(view)
end)
vim.bo[self.buf].modifiable = false
vim.cmd.redraw()
end
end

View File

@ -74,7 +74,17 @@ function M:update()
end
self:trim()
vim.bo[self.view.buf].modifiable = true
local view = vim.api.nvim_win_call(self.view.win, vim.fn.winsaveview)
self:render(self.view.buf)
vim.api.nvim_win_call(self.view.win, function()
vim.fn.winrestview(view)
end)
vim.bo[self.view.buf].modifiable = false
vim.diagnostic.set(
Config.ns,
self.view.buf,