From b6f7c193b07d17a921b2af509d704474fac77321 Mon Sep 17 00:00:00 2001 From: Maddison Hellstrom Date: Mon, 4 Nov 2024 13:28:29 -0800 Subject: [PATCH] fix: don't try to read non-files (#797) fixes #796 --- lua/avante/path.lua | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lua/avante/path.lua b/lua/avante/path.lua index f089c4a..e735803 100644 --- a/lua/avante/path.lua +++ b/lua/avante/path.lua @@ -85,12 +85,14 @@ Prompt.get = function(bufnr) local scanner = Scan.scan_dir(directory:absolute(), { depth = 1, add_dirs = true }) for _, entry in ipairs(scanner) do local file = Path:new(entry) - if entry:find("planning") and Prompt.templates.planning == nil then - Prompt.templates.planning = file:read() - elseif entry:find("editing") and Prompt.templates.editing == nil then - Prompt.templates.editing = file:read() - elseif entry:find("suggesting") and Prompt.templates.suggesting == nil then - Prompt.templates.suggesting = file:read() + if file:is_file() then + if entry:find("planning") and Prompt.templates.planning == nil then + Prompt.templates.planning = file:read() + elseif entry:find("editing") and Prompt.templates.editing == nil then + Prompt.templates.editing = file:read() + elseif entry:find("suggesting") and Prompt.templates.suggesting == nil then + Prompt.templates.suggesting = file:read() + end end end