chore: add guards to prepare setup refactoring

This commit is contained in:
kiyan
2022-02-11 11:06:11 +01:00
parent 0708a1c551
commit 0f7da146bf
5 changed files with 10 additions and 4 deletions

View File

@@ -371,7 +371,7 @@ end
local M = {}
function M.draw()
if not TreeExplorer or not api.nvim_buf_is_loaded(view.View.bufnr) then
if not TreeExplorer or not view.View.bufnr or not api.nvim_buf_is_loaded(view.View.bufnr) then
return
end
local cursor
@@ -404,7 +404,7 @@ function M.draw()
end
function M.render_hl(bufnr)
if not api.nvim_buf_is_loaded(bufnr) then return end
if not bufnr or not api.nvim_buf_is_loaded(bufnr) then return end
api.nvim_buf_clear_namespace(bufnr, namespace_id, 0, -1)
for _, data in ipairs(hl) do
api.nvim_buf_add_highlight(bufnr, namespace_id, data[1], data[2], data[3], data[4])