Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: cache opts.cwd so it cannot be changed by another function
Browse files Browse the repository at this point in the history
I'm not sure why but for me opts.cwd reverted back to my home directory
in the make_display function (while it's correct in the gen_from_fd
function). By caching it this way, it works fine 🤷

See also #70
entropitor authored and cljoly committed Mar 20, 2024

Partially verified

This commit is signed with the committer’s verified signature.
cljoly’s contribution has been verified via SSH key.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
1 parent b4c0b70 commit 7fbd86b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lua/telescope/_extensions/repo/main.lua
Original file line number Diff line number Diff line change
@@ -67,6 +67,9 @@ local function gen_from_fd(opts)
items = { {} },
})

-- This prevents opts.cwd from changing later when it’s called in the
-- display function
local cwd = opts.cwd
local function make_display(entry)
local dir = (function(path)
if path == Path.path.root() then
@@ -83,8 +86,8 @@ local function gen_from_fd(opts)
return p:shorten()
end

if vim.startswith(path, opts.cwd) and path ~= opts.cwd then
return Path:new(p):make_relative(opts.cwd)
if vim.startswith(path, cwd) and path ~= cwd then
return Path:new(p):make_relative(cwd)
end

if vim.startswith(path, os_home) then

0 comments on commit 7fbd86b

Please sign in to comment.