fix: safer teardown of buffer previewer (#1158)

This commit is contained in:
fdschmidt93
2021-08-23 20:20:41 +02:00
committed by GitHub
parent f45c170f28
commit 50e5e86ac3

View File

@@ -921,15 +921,17 @@ previewers.buffers = defaulter(function(opts)
return state
end,
teardown = function(self)
-- reapply proper buffer-window options..
for opt, value in pairs(self.state.win_options) do
vim.api.nvim_win_set_option(self.state.winid, opt, value)
end
-- TODO precautious clearing of extmark though likely no effect due to ephemeral
-- clear extmarks for previewed buffers
for buf, _ in pairs(self.state.previewed_buffers) do
if vim.api.nvim_buf_is_valid(buf) then
vim.api.nvim_buf_clear_namespace(buf, ns_previewer, 0, -1)
if self.state then
-- reapply proper buffer-window options..
for opt, value in pairs(self.state.win_options) do
vim.api.nvim_win_set_option(self.state.winid, opt, value)
end
-- TODO precautious clearing of extmark though likely no effect due to ephemeral
-- clear extmarks for previewed buffers
for buf, _ in pairs(self.state.previewed_buffers) do
if vim.api.nvim_buf_is_valid(buf) then
vim.api.nvim_buf_clear_namespace(buf, ns_previewer, 0, -1)
end
end
end
previewer_active = false