Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions lua/telescope/_extensions/git_worktree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,19 @@ local telescope_git_worktree = function(opts)
local index = #results + 1
for key, val in pairs(widths) do
if key == 'path' then
local new_path = utils.transform_path(opts, entry[key])
local path_len = strings.strdisplaywidth(new_path or "")
widths[key] = math.max(val, path_len)
-- Some users have found that transform_path raises an error because telescope.state#get_status
-- outputs an empty table. When that happens, we need to use the default value.
-- This seems to happen in distros such as AstroNvim and NvChad
--
-- Reference: https://github.com/ThePrimeagen/git-worktree.nvim/issues/97
local transformed_ok, new_path = pcall(utils.transform_path, opts, entry[key])

if transformed_ok then
local path_len = strings.strdisplaywidth(new_path or "")
widths[key] = math.max(val, path_len)
else
widths[key] = math.max(val, strings.strdisplaywidth(entry[key] or ""))
end
else
widths[key] = math.max(val, strings.strdisplaywidth(entry[key] or ""))
end
Expand Down