Skip to content

Commit 60fc176

Browse files
authored
fix: three bugs introduced by merged PRs (#17)
- fix(oop): use dot syntax for super_class call in CommitLogPanel (commit_log_panel.lua). The colon syntax constructed a spurious instance; every other super-call in the codebase uses dot access. - fix(actions): pass required opt table to vcs.get_adapter() in diff_against_default_branch (actions.lua). Calling with no argument crashed when no diffview was open. - fix(hg): guard get_commit_url call in open_commit_in_browser (file_history/listeners.lua). The method only exists on GitAdapter; HgAdapter users got a nil call crash.
1 parent 1eb2454 commit 60fc176

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

lua/diffview/actions.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,12 @@ function M.diff_against_default_branch()
225225
else
226226
-- Get an adapter for the current working directory.
227227
local err
228-
err, adapter = require("diffview.vcs").get_adapter()
228+
local cfile = pl:vim_expand("%")
229+
local top_indicators = utils.vec_join(
230+
vim.bo.buftype == "" and pl:absolute(cfile) or nil,
231+
pl:realpath(".")
232+
)
233+
err, adapter = require("diffview.vcs").get_adapter({ top_indicators = top_indicators })
229234
if err or not adapter then
230235
utils.err("Failed to get VCS adapter: " .. (err or "unknown error"))
231236
return

lua/diffview/scene/views/file_history/listeners.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,11 @@ return function(view)
280280
end
281281
if not item or not item.commit then return end
282282

283+
if not view.adapter.get_commit_url then
284+
utils.err("Opening commits in browser is not supported for this VCS.")
285+
return
286+
end
287+
283288
local url = view.adapter:get_commit_url(item.commit.hash)
284289
if not url then
285290
utils.err("Could not construct browser URL. Remote URL not recognized.")

lua/diffview/ui/panels/commit_log_panel.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function CommitLogPanel:init(parent, adapter, opt)
7676
end
7777

7878
function CommitLogPanel:init_buffer()
79-
CommitLogPanel:super_class().init_buffer(self)
79+
CommitLogPanel.super_class.init_buffer(self)
8080

8181
local conf = get_user_config().keymaps
8282
local default_opt = { silent = true, nowait = true, buffer = self.bufid }

0 commit comments

Comments
 (0)