From 36720ed0ac724fc7527a6a4cf920e13164039400 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Joly?= Date: Thu, 25 Apr 2024 11:25:17 +0000 Subject: [PATCH] fix: allow cached opts.cwd to be reset if nil MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sometimes, when we cache opts.cwd, it is still nil. While this problem is investigated [separately][1], it’s worth having this workaround, to be on the safe side. It’s very disruptive when items can’t be diplayed. [1]: https://github.com/cljoly/telescope-repo.nvim/pull/70#issuecomment-2014750473 Originally authored by @rish987 in #71. I’ve made cosmetic changes and added some comments. Co-authored-by: Rishikesh Vaishnav --- lua/telescope/_extensions/repo/main.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lua/telescope/_extensions/repo/main.lua b/lua/telescope/_extensions/repo/main.lua index 61008d7..ad497b6 100644 --- a/lua/telescope/_extensions/repo/main.lua +++ b/lua/telescope/_extensions/repo/main.lua @@ -71,6 +71,11 @@ local function gen_from_fd(opts) -- display function local cwd = opts.cwd local function make_display(entry) + -- The value `opts.cwd` might have been nil when it was fixed. This + -- resets it if it was nil. + if not cwd then + cwd = opts.cwd + end local dir = (function(path) if path == Path.path.root() then return path