Skip to content

Commit

Permalink
fix(diff): use git show when only displaying one commit (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdrouhard committed Dec 25, 2022
1 parent ed8259b commit 037f242
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 6 additions & 2 deletions lua/lazy/view/diff.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 1 addition & 3 deletions lua/lazy/view/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 037f242

Please sign in to comment.