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 return state
end, end,
teardown = function(self) teardown = function(self)
-- reapply proper buffer-window options.. if self.state then
for opt, value in pairs(self.state.win_options) do -- reapply proper buffer-window options..
vim.api.nvim_win_set_option(self.state.winid, opt, value) for opt, value in pairs(self.state.win_options) do
end vim.api.nvim_win_set_option(self.state.winid, opt, value)
-- TODO precautious clearing of extmark though likely no effect due to ephemeral end
-- clear extmarks for previewed buffers -- TODO precautious clearing of extmark though likely no effect due to ephemeral
for buf, _ in pairs(self.state.previewed_buffers) do -- clear extmarks for previewed buffers
if vim.api.nvim_buf_is_valid(buf) then for buf, _ in pairs(self.state.previewed_buffers) do
vim.api.nvim_buf_clear_namespace(buf, ns_previewer, 0, -1) if vim.api.nvim_buf_is_valid(buf) then
vim.api.nvim_buf_clear_namespace(buf, ns_previewer, 0, -1)
end
end end
end end
previewer_active = false previewer_active = false