feat: check type of path_display and warn user if wrong (#1023)
This commit is contained in:
@@ -281,34 +281,39 @@ utils.transform_path = function(opts, path)
|
|||||||
|
|
||||||
if type(path_display) == "function" then
|
if type(path_display) == "function" then
|
||||||
return path_display(opts, transformed_path)
|
return path_display(opts, transformed_path)
|
||||||
end
|
|
||||||
|
|
||||||
if utils.is_path_hidden(nil, path_display) then
|
elseif utils.is_path_hidden(nil, path_display) then
|
||||||
return ''
|
return ''
|
||||||
end
|
|
||||||
|
|
||||||
if vim.tbl_contains(path_display, "tail") or path_display.tail then
|
elseif type(path_display) == "table" then
|
||||||
transformed_path = utils.path_tail(transformed_path)
|
|
||||||
else
|
if vim.tbl_contains(path_display, "tail") or path_display.tail then
|
||||||
if not vim.tbl_contains(path_display, "absolute") or path_display.absolute == false then
|
transformed_path = utils.path_tail(transformed_path)
|
||||||
local cwd
|
else
|
||||||
if opts.cwd then
|
if not vim.tbl_contains(path_display, "absolute") or path_display.absolute == false then
|
||||||
cwd = opts.cwd
|
local cwd
|
||||||
if not vim.in_fast_event() then
|
if opts.cwd then
|
||||||
cwd = vim.fn.expand(opts.cwd)
|
cwd = opts.cwd
|
||||||
|
if not vim.in_fast_event() then
|
||||||
|
cwd = vim.fn.expand(opts.cwd)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
cwd = vim.loop.cwd();
|
||||||
end
|
end
|
||||||
else
|
transformed_path = Path:new(transformed_path):make_relative(cwd)
|
||||||
cwd = vim.loop.cwd();
|
end
|
||||||
|
|
||||||
|
if vim.tbl_contains(path_display, "shorten") or path_display["shorten"] ~= nil then
|
||||||
|
transformed_path = Path:new(transformed_path):shorten(path_display["shorten"])
|
||||||
end
|
end
|
||||||
transformed_path = Path:new(transformed_path):make_relative(cwd)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if vim.tbl_contains(path_display, "shorten") or path_display["shorten"] ~= nil then
|
return transformed_path
|
||||||
transformed_path = Path:new(transformed_path):shorten(path_display["shorten"])
|
else
|
||||||
end
|
log.warn("`path_display` must be either a function or a table.",
|
||||||
|
"See `:help telescope.defaults.path_display.")
|
||||||
|
return transformed_path
|
||||||
end
|
end
|
||||||
|
|
||||||
return transformed_path
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- local x = utils.make_default_callable(function(opts)
|
-- local x = utils.make_default_callable(function(opts)
|
||||||
|
|||||||
Reference in New Issue
Block a user