fix(file_selector): handle absolute and relative filepaths (#1342)

This commit is contained in:
LintaoAmons
2025-02-23 01:40:27 +08:00
committed by GitHub
parent 43bb2b3273
commit 7a49673023

View File

@@ -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