Skip to content

Commit

Permalink
fix: restore view after updating proofview window
Browse files Browse the repository at this point in the history
  • Loading branch information
tomtomjhj committed Dec 8, 2023
1 parent 15c078a commit 0dee175
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lua/vscoq/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,24 @@ end

---@param proofView vscoq.ProofViewNotification
function VSCoqNvim:proofView(proofView)
local lines = render.ProofView(proofView)
self:ensure_proofview_panel()

-- TODO: smarter view? relative position?
local wins = {} ---@type table<window, vim.fn.winsaveview.ret>
for _, win in ipairs(vim.fn.win_findbuf(self.proofview_panel) or {}) do
vim.api.nvim_win_call(win, function()
wins[win] = vim.fn.winsaveview()
end)
end

local lines = render.ProofView(proofView)
vim.api.nvim_buf_set_lines(self.proofview_panel, 0, -1, false, lines)

for win, view in pairs(wins) do
vim.api.nvim_win_call(win, function()
vim.fn.winrestview(view)
end)
end
end

-- TODO: commands in panels
Expand Down

0 comments on commit 0dee175

Please sign in to comment.