Skip to content

Commit

Permalink
fix(git_commits): fix wrong current buffer checking (#395)
Browse files Browse the repository at this point in the history
* fix(git_commits): fix current buffer checking

* chore
  • Loading branch information
linrongbin16 authored Nov 10, 2023
1 parent 623da80 commit fc59c35
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions lua/fzfx/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -440,34 +440,36 @@ local function _make_git_commits_provider(opts)
local function impl(query, context)
local git_root_cmd = cmd.GitRootCmd:run()
if git_root_cmd:wrong() then
log.echo(LogLevels.INFO, default_invalid_buffer_error)
return nil
end
if not utils.is_buf_valid(context.bufnr) then
log.echo(
LogLevels.INFO,
default_invalid_buffer_error,
vim.inspect(context.bufnr)
)
log.echo(LogLevels.INFO, default_git_root_error)
return nil
end
return (type(opts) == "table" and opts.buffer)
and {
"git",
"log",
"--pretty=" .. default_git_log_pretty,
"--date=short",
"--color=always",
"--",
vim.api.nvim_buf_get_name(context.bufnr),
}
or {
if type(opts) == "table" and opts.buffer then
if not utils.is_buf_valid(context.bufnr) then
log.echo(
LogLevels.INFO,
default_invalid_buffer_error,
vim.inspect(context.bufnr)
)
return nil
end
return {
"git",
"log",
"--pretty=" .. default_git_log_pretty,
"--date=short",
"--color=always",
"--",
vim.api.nvim_buf_get_name(context.bufnr),
}
else
return {
"git",
"log",
"--pretty=" .. default_git_log_pretty,
"--date=short",
"--color=always",
}
end
end
return impl
end
Expand Down Expand Up @@ -513,7 +515,7 @@ end
local function _git_blame_provider(query, context)
local git_root_cmd = cmd.GitRootCmd:run()
if git_root_cmd:wrong() then
log.echo(LogLevels.INFO, default_invalid_buffer_error)
log.echo(LogLevels.INFO, default_git_root_error)
return nil
end
if not utils.is_buf_valid(context.bufnr) then
Expand Down Expand Up @@ -554,7 +556,7 @@ local function _make_git_status_provider(opts)
local function impl()
local git_root_cmd = cmd.GitRootCmd:run()
if git_root_cmd:wrong() then
log.echo(LogLevels.INFO, default_invalid_buffer_error)
log.echo(LogLevels.INFO, default_git_root_error)
return nil
end
return (type(opts) == "table" and opts.current_folder)
Expand Down

0 comments on commit fc59c35

Please sign in to comment.