mirror of https://github.com/folke/lazy.nvim.git
fix(diff): use git show when only displaying one commit (#155)
This commit is contained in:
parent
ed8259b7c1
commit
037f242430
|
@ -32,10 +32,12 @@ M.handlers = {
|
||||||
|
|
||||||
---@type LazyDiffFun
|
---@type LazyDiffFun
|
||||||
git = function(plugin, diff)
|
git = function(plugin, diff)
|
||||||
local cmd = { "git", "diff" }
|
local cmd = { "git" }
|
||||||
if diff.commit then
|
if diff.commit then
|
||||||
|
cmd[#cmd + 1] = "show"
|
||||||
cmd[#cmd + 1] = diff.commit
|
cmd[#cmd + 1] = diff.commit
|
||||||
else
|
else
|
||||||
|
cmd[#cmd + 1] = "diff"
|
||||||
cmd[#cmd + 1] = diff.from
|
cmd[#cmd + 1] = diff.from
|
||||||
cmd[#cmd + 1] = diff.to
|
cmd[#cmd + 1] = diff.to
|
||||||
end
|
end
|
||||||
|
@ -44,10 +46,12 @@ M.handlers = {
|
||||||
|
|
||||||
---@type LazyDiffFun
|
---@type LazyDiffFun
|
||||||
terminal_git = function(plugin, diff)
|
terminal_git = function(plugin, diff)
|
||||||
local cmd = { "git", "diff" }
|
local cmd = { "git" }
|
||||||
if diff.commit then
|
if diff.commit then
|
||||||
|
cmd[#cmd + 1] = "show"
|
||||||
cmd[#cmd + 1] = diff.commit
|
cmd[#cmd + 1] = diff.commit
|
||||||
else
|
else
|
||||||
|
cmd[#cmd + 1] = "diff"
|
||||||
cmd[#cmd + 1] = diff.from
|
cmd[#cmd + 1] = diff.from
|
||||||
cmd[#cmd + 1] = diff.to
|
cmd[#cmd + 1] = diff.to
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,14 +38,12 @@ function M.show(mode)
|
||||||
M.view:update()
|
M.view:update()
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param opts? {mode?:string}
|
function M.create()
|
||||||
function M.create(opts)
|
|
||||||
local self = setmetatable({}, { __index = setmetatable(M, { __index = Float }) })
|
local self = setmetatable({}, { __index = setmetatable(M, { __index = Float }) })
|
||||||
---@cast self LazyView
|
---@cast self LazyView
|
||||||
Float.init(self)
|
Float.init(self)
|
||||||
|
|
||||||
require("lazy.view.colors").setup()
|
require("lazy.view.colors").setup()
|
||||||
opts = opts or {}
|
|
||||||
|
|
||||||
self.state = vim.deepcopy(default_state)
|
self.state = vim.deepcopy(default_state)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue