feat: check type of path_display and warn user if wrong (#1023)

This commit is contained in:
Luke Kershaw
2021-07-18 12:19:27 +01:00
committed by GitHub
parent 1bb73aed5f
commit 8c3f2b630b

View File

@@ -281,11 +281,11 @@ 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
elseif type(path_display) == "table" then
if vim.tbl_contains(path_display, "tail") or path_display.tail then if vim.tbl_contains(path_display, "tail") or path_display.tail then
transformed_path = utils.path_tail(transformed_path) transformed_path = utils.path_tail(transformed_path)
@@ -309,6 +309,11 @@ utils.transform_path = function(opts, path)
end end
return transformed_path return transformed_path
else
log.warn("`path_display` must be either a function or a table.",
"See `:help telescope.defaults.path_display.")
return transformed_path
end
end end
-- local x = utils.make_default_callable(function(opts) -- local x = utils.make_default_callable(function(opts)