From 657b418c4603d9e079c18e38f5b3b7ffb837f9db Mon Sep 17 00:00:00 2001 From: yetone Date: Sat, 2 Aug 2025 17:52:31 +0800 Subject: [PATCH] fix: check if path is a directory before opening it --- lua/avante/llm_tools/edit_file.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/avante/llm_tools/edit_file.lua b/lua/avante/llm_tools/edit_file.lua index 3e34b2a..5be00e6 100644 --- a/lua/avante/llm_tools/edit_file.lua +++ b/lua/avante/llm_tools/edit_file.lua @@ -65,6 +65,9 @@ M.func = vim.schedule_wrap(function(input, opts) if not input.path then return false, "path not provided" end + --- if input.path is a directory, return false + if vim.fn.isdirectory(input.path) == 1 then return false, "path is a directory" end + local ok, lines = pcall(Utils.read_file_from_buf_or_disk, input.path) if not ok then local f = io.open(input.path, "r")