Skip to content

Commit

Permalink
fix(preview): unload preview buffer again when closing and when it wa…
Browse files Browse the repository at this point in the history
…snt loaded before
  • Loading branch information
folke committed Oct 24, 2023
1 parent bd9eac4 commit ce73f21
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lua/trouble/view/preview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@ function M.close()
end
Render.reset(preview.buf)
if vim.api.nvim_win_is_valid(preview.win) then
Render.reset(vim.api.nvim_win_get_buf(preview.win))
local other = vim.api.nvim_win_get_buf(preview.win)
Render.reset(other)
Util.noautocmd(function()
vim.api.nvim_win_set_buf(preview.win, preview.buf)
vim.api.nvim_win_call(preview.win, function()
vim.fn.winrestview(preview.view)
end)
-- if the buffer we are previewing wasn't previously loaded,
-- unload it again
if vim.b[other].trouble_preview then
vim.api.nvim_buf_delete(other, { unload = true })
vim.b[other].trouble_preview = nil
end
end)
end
end
Expand Down

0 comments on commit ce73f21

Please sign in to comment.