Skip to content

Commit

Permalink
fix: don't try to read non-files (#797)
Browse files Browse the repository at this point in the history
fixes #796
  • Loading branch information
b0o authored Nov 4, 2024
1 parent cb09c74 commit b6f7c19
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lua/avante/path.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit b6f7c19

Please sign in to comment.