Skip to content

Commit

Permalink
fix(git): show status after cd
Browse files Browse the repository at this point in the history
parse `git status --porcelain -- .` based on git toplevel directory
stored in new field `git_root`.

closes #309
  • Loading branch information
jamestrew committed Sep 15, 2023
1 parent ad7b637 commit 0a27e53
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lua/telescope/_extensions/file_browser/finders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ fb_finders.browse_files = function(opts)
local git_file_status = {}
if opts.git_status then
local git_status = Job:new({ cwd = opts.path, command = "git", args = git_args() }):sync()
git_file_status = fb_git.parse_status_output(git_status, opts.cwd)
git_file_status = fb_git.parse_status_output(git_status, opts.git_root)
end
if opts.path ~= os_sep and not opts.hide_parent_dir then
table.insert(data, 1, parent_path)
Expand Down Expand Up @@ -184,6 +184,8 @@ fb_finders.finder = function(opts)
hidden = vim.tbl_extend("keep", hidden, hidden_default)
end

local git_root = Job:new({ command = "git", args = { "rev-parse", "--show-toplevel" } }):sync()[1]

return setmetatable({
cwd_to_path = opts.cwd_to_path,
cwd = opts.cwd_to_path and opts.path or opts.cwd, -- nvim cwd
Expand All @@ -199,7 +201,8 @@ fb_finders.finder = function(opts)
select_buffer = vim.F.if_nil(opts.select_buffer, false),
hide_parent_dir = vim.F.if_nil(opts.hide_parent_dir, false),
collapse_dirs = vim.F.if_nil(opts.collapse_dirs, false),
git_status = vim.F.if_nil(opts.git_status, true),
git_status = vim.F.if_nil(opts.git_status, git_root ~= nil),
git_root = git_root,
-- ensure we forward make_entry opts adequately
entry_maker = vim.F.if_nil(opts.entry_maker, function(local_opts)
return fb_make_entry(vim.tbl_extend("force", opts, local_opts))
Expand Down

0 comments on commit 0a27e53

Please sign in to comment.