Skip to content

Commit

Permalink
fix(inlay-hints): check if buffer is unloaded
Browse files Browse the repository at this point in the history
fix #756
  • Loading branch information
lukas-reineke committed Oct 28, 2023
1 parent 046e2cf commit 64fdadb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lua/ibl/inlay_hints.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ local buffer_state = {}
---@param hl string|string[]
---@param hl_empty string
local set_extmark = function(bufnr, row, col, hl, hl_empty)
if not vim.api.nvim_buf_is_loaded(bufnr) then
return
end
local inlayhint_extmarks = vim.api.nvim_buf_get_extmarks(
bufnr,
inlayhint_namespace,
Expand Down Expand Up @@ -63,7 +66,7 @@ end
---@param bufnr number
M.clear_buffer = function(bufnr)
for _, row in ipairs(buffer_state[bufnr] or {}) do
set_extmark(bufnr, row, 0, "LspInlayHint", "")
pcall(set_extmark, bufnr, row, 0, "LspInlayHint", "")
end

buffer_state[bufnr] = nil
Expand Down

0 comments on commit 64fdadb

Please sign in to comment.