Skip to content

Commit ca8a541

Browse files
entropitorcljoly
authored andcommitted
fix: cache opts.cwd so it cannot be changed by another function
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
1 parent b4c0b70 commit ca8a541

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lua/telescope/_extensions/repo/main.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ local function gen_from_fd(opts)
6767
items = { {} },
6868
})
6969

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

86-
if vim.startswith(path, opts.cwd) and path ~= opts.cwd then
87-
return Path:new(p):make_relative(opts.cwd)
89+
if vim.startswith(path, cwd) and path ~= cwd then
90+
return Path:new(p):make_relative(cwd)
8891
end
8992

9093
if vim.startswith(path, os_home) then

0 commit comments

Comments
 (0)