fix: path shortening does proper subpath detection
This commit is contained in:
parent
164135793d
commit
054247b9c1
1 changed files with 2 additions and 2 deletions
|
|
@ -116,14 +116,14 @@ local home_dir = assert(uv.os_homedir())
|
||||||
---@return string
|
---@return string
|
||||||
M.shorten_path = function(path)
|
M.shorten_path = function(path)
|
||||||
local cwd = vim.fn.getcwd()
|
local cwd = vim.fn.getcwd()
|
||||||
if vim.startswith(path, cwd) then
|
if M.is_subpath(cwd, path) then
|
||||||
local relative = path:sub(cwd:len() + 2)
|
local relative = path:sub(cwd:len() + 2)
|
||||||
if relative == "" then
|
if relative == "" then
|
||||||
relative = "."
|
relative = "."
|
||||||
end
|
end
|
||||||
return relative
|
return relative
|
||||||
end
|
end
|
||||||
if vim.startswith(path, home_dir) then
|
if M.is_subpath(home_dir, path) then
|
||||||
return "~" .. path:sub(home_dir:len() + 1)
|
return "~" .. path:sub(home_dir:len() + 1)
|
||||||
end
|
end
|
||||||
return path
|
return path
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue