fix: check for nil bufnr to avoid messing up the UI when rendering
This commit is contained in:
parent
911bc278d7
commit
e9548d7992
@ -156,6 +156,7 @@ end
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M.draw(tree, reload)
|
function M.draw(tree, reload)
|
||||||
|
if not tree.bufnr then return end
|
||||||
api.nvim_buf_set_option(tree.bufnr, 'modifiable', true)
|
api.nvim_buf_set_option(tree.bufnr, 'modifiable', true)
|
||||||
local cursor = api.nvim_win_get_cursor(tree.winnr)
|
local cursor = api.nvim_win_get_cursor(tree.winnr)
|
||||||
if reload then
|
if reload then
|
||||||
@ -174,6 +175,7 @@ function M.draw(tree, reload)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.render_hl(bufnr)
|
function M.render_hl(bufnr)
|
||||||
|
if not bufnr then return end
|
||||||
api.nvim_buf_clear_namespace(bufnr, namespace_id, 0, -1)
|
api.nvim_buf_clear_namespace(bufnr, namespace_id, 0, -1)
|
||||||
for _, data in ipairs(hl) do
|
for _, data in ipairs(hl) do
|
||||||
api.nvim_buf_add_highlight(bufnr, namespace_id, data[1], data[2], data[3], data[4])
|
api.nvim_buf_add_highlight(bufnr, namespace_id, data[1], data[2], data[3], data[4])
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user