Skip to content

Conversation

@GustavEikaas
Copy link

@GustavEikaas GustavEikaas commented Nov 27, 2024

This was a weird bug and I want someone to confirm that it also happens on their machines.

When running require('telescope').extensions.git_worktree.git_worktrees() it opens a telescope picker with no entries.
Checking :messages gives the following output

[telescope] [WARN  20:03:04] C:/Users/Gustav/AppData/Local/nvim-data/lazy/telescope.nvim/lua/telescope/pickers.lua:672: Finder failed with msg:  ...lazy/telescope.nvim/lua/telescope/pickers/highlights.lua:33: Invalid 'hl_group': Expected Lua string

This is weird right?

Turns out that this function is the culprit

    local make_display = function(entry)
        return displayer {
            { entry.branch, "TelescopeResultsIdentifier" },
            { utils.transform_path(opts, entry.path) },
            { entry.sha },
        }
    end

Can you spot the bug?

Turns out utils.transform_path has more than one return value, meaning that if you do something like this
local path, arg = utils.transform_path(a,b) returns the following "abc", {} . Given the way this function is inlined into the arguments of the displayer it captures both values instead of only the intended string. Thus giving you the error of Expected Lua string.

Easily fixed by just discarding the second return value

 local make_display = function(entry)
        local path = utils.transform_path(opts, entry.path)
        return displayer {
            { entry.branch, "TelescopeResultsIdentifier" },
            { path },
            { entry.sha },
        }
    end

@GustavEikaas GustavEikaas changed the title fix(telescope): worktree list crashing fix(telescope):🐛 worktree list crashing Nov 27, 2024
@phtea
Copy link

phtea commented Jun 26, 2025

this must be merged!
independently of you I tried to fix it myself and I fixed it a bit different:
#135

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants