From d3e0352574731ae47b2ad2e4683c326ae5b2a549 Mon Sep 17 00:00:00 2001 From: Chinmay Dalal Date: Tue, 20 Jun 2023 22:06:31 +0530 Subject: [PATCH] fix(lsp): check if inlay hints are enabled for a buffer before disabling (#24074) disabling before enabling throws an error otherwise, because bufstate[bufnr] doesn't exist --- runtime/lua/vim/lsp/_inlay_hint.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/runtime/lua/vim/lsp/_inlay_hint.lua b/runtime/lua/vim/lsp/_inlay_hint.lua index bdce464480..e7cc8ba7ae 100644 --- a/runtime/lua/vim/lsp/_inlay_hint.lua +++ b/runtime/lua/vim/lsp/_inlay_hint.lua @@ -207,9 +207,11 @@ end ---@private function M.disable(bufnr) bufnr = resolve_bufnr(bufnr) - clear(bufnr) - bufstates[bufnr].enabled = nil - bufstates[bufnr].timer = nil + if bufstates[bufnr] and bufstates[bufnr].enabled then + clear(bufnr) + bufstates[bufnr].enabled = nil + bufstates[bufnr].timer = nil + end end --- Toggle inlay hints for a buffer