Skip to content

Commit

Permalink
Rename callback to on_open
Browse files Browse the repository at this point in the history
  • Loading branch information
CKolkey committed Nov 28, 2023
1 parent c1ff05e commit a177fac
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions lua/neogit/buffers/refs_view/ui.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local M = {}

local a = require("plenary.async")
local Ui = require("neogit.lib.ui")
local util = require("neogit.lib.util")
local git = require("neogit.lib.git")
Expand Down Expand Up @@ -54,14 +55,26 @@ local function section(refs, heading, head)
for _, ref in ipairs(refs) do
table.insert(
rows,
col({ Ref(ref) }, {
col.tag("Ref")({ Ref(ref) }, {
oid = ref.oid,
foldable = true,
callback = a.void(function(c)
vim.cmd("echomsg 'Getting cherries for " .. ref.oid .. "'")
on_open = a.void(function(this, ui)
vim.cmd(string.format("echomsg 'Getting cherries for %s'", ref.oid:sub(1, 7)))

local cherries = Cherries(ref, head)
vim.cmd("echomsg ''")
P { cherries }
if cherries.children[1] then
this.options.on_open = nil -- Don't call this again
this.options.foldable = true
this.options.folded = false

vim.cmd("norm! zE") -- Eliminate all existing folds
this:append(cherries)
ui:update()

vim.cmd(string.format("redraw | echomsg 'Got %d cherries for %s'", #cherries.children - 1, ref.oid:sub(1, 7)))
else
vim.cmd(string.format("redraw | echomsg 'No cherries found for %s'", ref.oid:sub(1, 7)))
end
end),
})
)
Expand Down

0 comments on commit a177fac

Please sign in to comment.