fix(utils): transform_path filename_first composability (#3065)
* Moves filename_first to last position to fix issues with composing other options * Adds comment
This commit is contained in:
@@ -307,6 +307,28 @@ utils.transform_path = function(opts, path)
|
|||||||
transformed_path = Path:new(transformed_path):make_relative(cwd)
|
transformed_path = Path:new(transformed_path):make_relative(cwd)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if vim.tbl_contains(path_display, "shorten") or path_display["shorten"] ~= nil then
|
||||||
|
if type(path_display["shorten"]) == "table" then
|
||||||
|
local shorten = path_display["shorten"]
|
||||||
|
transformed_path = Path:new(transformed_path):shorten(shorten.len, shorten.exclude)
|
||||||
|
else
|
||||||
|
local length = type(path_display["shorten"]) == "number" and path_display["shorten"]
|
||||||
|
transformed_path = Path:new(transformed_path):shorten(length)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if vim.tbl_contains(path_display, "truncate") or path_display.truncate then
|
||||||
|
if opts.__length == nil then
|
||||||
|
opts.__length = calc_result_length(path_display.truncate)
|
||||||
|
end
|
||||||
|
if opts.__prefix == nil then
|
||||||
|
opts.__prefix = 0
|
||||||
|
end
|
||||||
|
transformed_path = truncate(transformed_path, opts.__length - opts.__prefix, nil, -1)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- IMPORTANT: filename_first needs to be the last option. Otherwise the
|
||||||
|
-- other options will not be displayed correctly.
|
||||||
if vim.tbl_contains(path_display, "filename_first") or path_display["filename_first"] ~= nil then
|
if vim.tbl_contains(path_display, "filename_first") or path_display["filename_first"] ~= nil then
|
||||||
local reverse_directories = false
|
local reverse_directories = false
|
||||||
|
|
||||||
@@ -337,26 +359,6 @@ utils.transform_path = function(opts, path)
|
|||||||
|
|
||||||
path_style = { { { #filename, #transformed_path }, "TelescopeResultsComment" } }
|
path_style = { { { #filename, #transformed_path }, "TelescopeResultsComment" } }
|
||||||
end
|
end
|
||||||
|
|
||||||
if vim.tbl_contains(path_display, "shorten") or path_display["shorten"] ~= nil then
|
|
||||||
if type(path_display["shorten"]) == "table" then
|
|
||||||
local shorten = path_display["shorten"]
|
|
||||||
transformed_path = Path:new(transformed_path):shorten(shorten.len, shorten.exclude)
|
|
||||||
else
|
|
||||||
local length = type(path_display["shorten"]) == "number" and path_display["shorten"]
|
|
||||||
transformed_path = Path:new(transformed_path):shorten(length)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if vim.tbl_contains(path_display, "truncate") or path_display.truncate then
|
|
||||||
if opts.__length == nil then
|
|
||||||
opts.__length = calc_result_length(path_display.truncate)
|
|
||||||
end
|
|
||||||
if opts.__prefix == nil then
|
|
||||||
opts.__prefix = 0
|
|
||||||
end
|
|
||||||
transformed_path = truncate(transformed_path, opts.__length - opts.__prefix, nil, -1)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return transformed_path, path_style
|
return transformed_path, path_style
|
||||||
|
|||||||
Reference in New Issue
Block a user