fix(diff): use git show when only displaying one commit (#155)

This commit is contained in:
jdrouhard 2022-12-25 06:45:56 -06:00 committed by GitHub
parent ed8259b7c1
commit 037f242430
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -32,10 +32,12 @@ M.handlers = {
---@type LazyDiffFun
git = function(plugin, diff)
local cmd = { "git", "diff" }
local cmd = { "git" }
if diff.commit then
cmd[#cmd + 1] = "show"
cmd[#cmd + 1] = diff.commit
else
cmd[#cmd + 1] = "diff"
cmd[#cmd + 1] = diff.from
cmd[#cmd + 1] = diff.to
end
@ -44,10 +46,12 @@ M.handlers = {
---@type LazyDiffFun
terminal_git = function(plugin, diff)
local cmd = { "git", "diff" }
local cmd = { "git" }
if diff.commit then
cmd[#cmd + 1] = "show"
cmd[#cmd + 1] = diff.commit
else
cmd[#cmd + 1] = "diff"
cmd[#cmd + 1] = diff.from
cmd[#cmd + 1] = diff.to
end

View File

@ -38,14 +38,12 @@ function M.show(mode)
M.view:update()
end
---@param opts? {mode?:string}
function M.create(opts)
function M.create()
local self = setmetatable({}, { __index = setmetatable(M, { __index = Float }) })
---@cast self LazyView
Float.init(self)
require("lazy.view.colors").setup()
opts = opts or {}
self.state = vim.deepcopy(default_state)