From 8346d9b0058e2051a367a682f4459a789a0fa0ea Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Wed, 2 Jul 2025 23:45:35 -0700 Subject: [PATCH] fix: don't throw errors when closing code window (#2401) --- lua/avante/sidebar.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/avante/sidebar.lua b/lua/avante/sidebar.lua index 2a11018..a4f7f78 100644 --- a/lua/avante/sidebar.lua +++ b/lua/avante/sidebar.lua @@ -218,7 +218,9 @@ end function Sidebar:recover_code_winhl() if self.code.old_winhl ~= nil then - vim.wo[self.code.winid].winhl = self.code.old_winhl + if self.code.winid and api.nvim_win_is_valid(self.code.winid) then + vim.wo[self.code.winid].winhl = self.code.old_winhl + end self.code.old_winhl = nil end end