fix(lualine): weird path truncation when not under cwd/root

It does not make sense to truncate unless root actually in path.

Also, should probably check if opts.relative == "root"
otherwise the substitution can be surprising
(since user expects substitution only wrt. cwd)
This commit is contained in:
patnr 2024-09-11 12:09:11 +02:00
parent 3dbace941e
commit 772dd5c32f

View file

@ -96,7 +96,7 @@ function M.pretty_path(opts)
if opts.relative == "cwd" and path:find(cwd, 1, true) == 1 then if opts.relative == "cwd" and path:find(cwd, 1, true) == 1 then
path = path:sub(#cwd + 2) path = path:sub(#cwd + 2)
else elseif opts.relative == "root" and path:find(root, 1, true) == 1 then
path = path:sub(#root + 2) path = path:sub(#root + 2)
end end