diff --git a/lua/avante/file_selector.lua b/lua/avante/file_selector.lua index 3d32e2344..c5241d652 100644 --- a/lua/avante/file_selector.lua +++ b/lua/avante/file_selector.lua @@ -35,8 +35,7 @@ end function FileSelector:add_selected_file(filepath) if not filepath or filepath == "" then return end - -- if the file is in the current working directory then we can make it uniform the path - local uniform_path = Utils.file.is_in_cwd(filepath) and Utils.uniform_path(filepath) or filepath + local uniform_path = Utils.uniform_path(filepath) -- Avoid duplicates if not vim.tbl_contains(self.selected_filepaths, uniform_path) then diff --git a/lua/avante/utils/init.lua b/lua/avante/utils/init.lua index 92b8be237..73b20f81a 100644 --- a/lua/avante/utils/init.lua +++ b/lua/avante/utils/init.lua @@ -826,6 +826,7 @@ function M.get_current_selection_diagnostics(bufnr, selection) end function M.uniform_path(path) + if not M.file.is_in_cwd(path) then return path end local project_root = M.get_project_root() local abs_path = Path:new(project_root):joinpath(path):absolute() local relative_path = Path:new(abs_path):make_relative(project_root)