From 25bfb3240697128ec46992164d5dfeaf5c483811 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 25 Jan 2025 22:44:24 +0100 Subject: [PATCH] Fallback `use_file_path` to vim.loop.cwd() --- lua/telescope/builtin/__git.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lua/telescope/builtin/__git.lua b/lua/telescope/builtin/__git.lua index b242670..34b9c87 100644 --- a/lua/telescope/builtin/__git.lua +++ b/lua/telescope/builtin/__git.lua @@ -454,7 +454,9 @@ local try_worktrees = function(opts) end end - error(opts.cwd .. " is not a git directory") + local cwd = opts.cwd + opts.cwd = nil + return cwd end local current_path_toplevel = function() @@ -474,7 +476,9 @@ local set_opts_cwd = function(opts) if not opts.cwd then opts.cwd = vim.fn.expand "%:p:h" try_worktrees(opts) - return + if not opts.cwd then + opts.cwd = vim.loop.cwd() + end end else opts.cwd = vim.loop.cwd() @@ -487,7 +491,10 @@ local set_opts_cwd = function(opts) local in_bare = utils.get_os_command_output({ "git", "rev-parse", "--is-bare-repository" }, opts.cwd) if in_worktree[1] ~= "true" and in_bare[1] ~= "true" then - try_worktrees(opts) + local cwd = try_worktrees(opts) + if not opts.cwd then + error(cwd .. " is not a git directory") + end elseif in_worktree[1] ~= "true" and in_bare[1] == "true" then opts.is_bare = true end