From 037f2424303118b1a8312ed31081f518735823d5 Mon Sep 17 00:00:00 2001 From: jdrouhard Date: Sun, 25 Dec 2022 06:45:56 -0600 Subject: [PATCH] fix(diff): use git show when only displaying one commit (#155) --- lua/lazy/view/diff.lua | 8 ++++++-- lua/lazy/view/init.lua | 4 +--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lua/lazy/view/diff.lua b/lua/lazy/view/diff.lua index adff761..03c47c4 100644 --- a/lua/lazy/view/diff.lua +++ b/lua/lazy/view/diff.lua @@ -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 diff --git a/lua/lazy/view/init.lua b/lua/lazy/view/init.lua index e2d39c0..1f6266b 100644 --- a/lua/lazy/view/init.lua +++ b/lua/lazy/view/init.lua @@ -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)