From 1a6d1d6af40a13769bf9e9cf86ad8c2cbfda9e67 Mon Sep 17 00:00:00 2001 From: yetone Date: Wed, 2 Jul 2025 17:09:46 +0800 Subject: [PATCH] fix: the content is table (#2394) --- lua/avante/llm_tools/write_to_file.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/avante/llm_tools/write_to_file.lua b/lua/avante/llm_tools/write_to_file.lua index fbaf3dc..4df1f73 100644 --- a/lua/avante/llm_tools/write_to_file.lua +++ b/lua/avante/llm_tools/write_to_file.lua @@ -66,6 +66,7 @@ function M.func(opts, on_log, on_complete, session_ctx) local abs_path = Helpers.get_abs_path(opts.path) if not Helpers.has_permission_to_access(abs_path) then return false, "No permission to access path: " .. abs_path end if opts.content == nil then return false, "content not provided" end + if type(opts.content) ~= "string" then opts.content = vim.json.encode(opts.content) end local old_lines = Utils.read_file_from_buf_or_disk(abs_path) local old_content = table.concat(old_lines or {}, "\n") local str_replace = require("avante.llm_tools.str_replace")