Skip to content

Commit

Permalink
refactor and move abs path handling into uniform path
Browse files Browse the repository at this point in the history
  • Loading branch information
brewinski committed Jan 10, 2025
1 parent 4d78f7c commit bfea879
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lua/avante/file_selector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lua/avante/utils/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit bfea879

Please sign in to comment.