From 7d1698f3d88b448e0639974248cc17f49b7b8acf Mon Sep 17 00:00:00 2001 From: James Trew <66286082+jamestrew@users.noreply.github.com> Date: Sat, 20 Apr 2024 22:14:52 -0400 Subject: [PATCH] fix(utils): transform_path always return styling (#3067) * fix(utils): transform_path always return styling * fix docs/type hints * [docgen] Update doc/telescope.txt skip-checks: true --------- Co-authored-by: Github Actions --- doc/telescope.txt | 3 ++- lua/telescope/utils.lua | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/telescope.txt b/doc/telescope.txt index b241b27..25255db 100644 --- a/doc/telescope.txt +++ b/doc/telescope.txt @@ -2592,7 +2592,8 @@ utils.transform_path({opts}, {path}) *telescope.utils.transform_path()* {path} (string|nil) The path that should be formatted Return: ~ - string: The transformed path ready to be displayed + string: path to be displayed + table: The transformed path ready to be displayed with the styling utils.has_ts_parser({lang}) *telescope.utils.has_ts_parser()* diff --git a/lua/telescope/utils.lua b/lua/telescope/utils.lua index d14992f..3807357 100644 --- a/lua/telescope/utils.lua +++ b/lua/telescope/utils.lua @@ -270,7 +270,8 @@ end --- not be addressed by us ---@param opts table: The opts the users passed into the picker. Might contains a path_display key ---@param path string|nil: The path that should be formatted ----@return string, table: The transformed path ready to be displayed with the styling (or nil) +---@return string: path to be displayed +---@return table: The transformed path ready to be displayed with the styling utils.transform_path = function(opts, path) if path == nil then return "", {} @@ -279,13 +280,14 @@ utils.transform_path = function(opts, path) return path, {} end + ---@type fun(opts:table, path: string): string local path_display = vim.F.if_nil(opts.path_display, require("telescope.config").values.path_display) local transformed_path = path local path_style = {} if type(path_display) == "function" then - return path_display(opts, transformed_path) + return path_display(opts, transformed_path), path_style elseif utils.is_path_hidden(nil, path_display) then return "", path_style elseif type(path_display) == "table" then