From bfe840416142d9a34ce21d9dc6d9680c9d7c8f21 Mon Sep 17 00:00:00 2001 From: yetone Date: Thu, 20 Mar 2025 03:04:30 +0800 Subject: [PATCH] fix: treesitter fold (#1647) --- lua/avante/sidebar.lua | 52 +++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/lua/avante/sidebar.lua b/lua/avante/sidebar.lua index d980e76..1bb15e8 100644 --- a/lua/avante/sidebar.lua +++ b/lua/avante/sidebar.lua @@ -2506,32 +2506,6 @@ function Sidebar:create_input_container(opts) return end - local model = Config.has_provider(Config.provider) and Config.get_provider_config(Config.provider).model - or "default" - - local timestamp = get_timestamp() - - local selected_filepaths = self.file_selector:get_selected_filepaths() - - ---@type AvanteSelectedCode | nil - local selected_code = nil - if self.code.selection ~= nil then - selected_code = { - path = self.code.selection.filepath, - file_type = self.code.selection.filetype, - content = self.code.selection.content, - } - end - - local content_prefix = - render_chat_record_prefix(timestamp, Config.provider, model, request, selected_filepaths, selected_code) - - --- HACK: we need to set focus to true and scroll to false to - --- prevent the cursor from jumping to the bottom of the - --- buffer at the beginning - self:update_content("", { focus = true, scroll = false }) - self:update_content(content_prefix .. generating_text) - if request:sub(1, 1) == "/" then local command, args = request:match("^/(%S+)%s*(.*)") if command == nil then @@ -2559,6 +2533,32 @@ function Sidebar:create_input_container(opts) end end + local model = Config.has_provider(Config.provider) and Config.get_provider_config(Config.provider).model + or "default" + + local timestamp = get_timestamp() + + local selected_filepaths = self.file_selector:get_selected_filepaths() + + ---@type AvanteSelectedCode | nil + local selected_code = nil + if self.code.selection ~= nil then + selected_code = { + path = self.code.selection.filepath, + file_type = self.code.selection.filetype, + content = self.code.selection.content, + } + end + + local content_prefix = + render_chat_record_prefix(timestamp, Config.provider, model, request, selected_filepaths, selected_code) + + --- HACK: we need to set focus to true and scroll to false to + --- prevent the cursor from jumping to the bottom of the + --- buffer at the beginning + self:update_content("", { focus = true, scroll = false }) + self:update_content(content_prefix .. generating_text) + local original_response = "" local transformed_response = "" local displayed_response = ""