From 5d334b9f579aacd09603dd9e19b6730fbfcf4c72 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sat, 29 Jun 2024 13:58:13 +0200 Subject: [PATCH] fix(ui): save/restore view right before/after rendering --- lua/lazy/view/init.lua | 6 ------ lua/lazy/view/render.lua | 10 ++++++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lua/lazy/view/init.lua b/lua/lazy/view/init.lua index 26383da..b27a17e 100644 --- a/lua/lazy/view/init.lua +++ b/lua/lazy/view/init.lua @@ -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 diff --git a/lua/lazy/view/render.lua b/lua/lazy/view/render.lua index 640e9b0..b7bd884 100644 --- a/lua/lazy/view/render.lua +++ b/lua/lazy/view/render.lua @@ -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,