From 7a49673023bcd6fc5e616f8b7db9d2777f0693e8 Mon Sep 17 00:00:00 2001 From: LintaoAmons Date: Sun, 23 Feb 2025 01:40:27 +0800 Subject: [PATCH] fix(file_selector): handle absolute and relative filepaths (#1342) --- lua/avante/file_selector.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/avante/file_selector.lua b/lua/avante/file_selector.lua index 76e4a16..59d475b 100644 --- a/lua/avante/file_selector.lua +++ b/lua/avante/file_selector.lua @@ -89,7 +89,8 @@ end function FileSelector:add_selected_file(filepath) if not filepath or filepath == "" then return end - local absolute_path = Path:new(Utils.get_project_root()):joinpath(filepath):absolute() + local absolute_path = filepath:sub(1, 1) == "/" and filepath + or Path:new(Utils.get_project_root()):joinpath(filepath):absolute() local stat = vim.loop.fs_stat(absolute_path) if stat and stat.type == "directory" then