From 6c9c4365a210ff6e5a1c9aca5aa553d973cb02d6 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Tue, 22 Jul 2025 20:43:34 -0700 Subject: [PATCH] fix(sidebar): do not error when selecting text from help window (#2514) --- lua/avante/sidebar.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lua/avante/sidebar.lua b/lua/avante/sidebar.lua index e0452bd..52abe71 100644 --- a/lua/avante/sidebar.lua +++ b/lua/avante/sidebar.lua @@ -1364,9 +1364,8 @@ function Sidebar:on_mount(opts) -- Treesitter highlighting is active in the code buffer, activate it -- it in code selection buffer as well. local filetype = vim.bo[self.code.bufnr].filetype - if filetype and filetype ~= "" then - vim.treesitter.start(selected_code_buf, vim.bo[self.code.bufnr].filetype) - end + local lang = vim.treesitter.language.get_lang(filetype or "") + if lang and lang ~= "" then vim.treesitter.start(selected_code_buf, lang) end end -- Try the old syntax highlighting local syntax = api.nvim_get_option_value("syntax", { buf = self.code.bufnr })