Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(telescope):🐛 worktree list crashing #132

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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
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.

1 participant