fix(git): preserve dispatch and content after jumping back

This commit is contained in:
2026-05-08 01:46:43 +02:00
parent 4649b803ab
commit 867b5c2a2e
4 changed files with 78 additions and 12 deletions
+5 -8
View File
@@ -47,14 +47,13 @@ local function fetch(worktree, max_count)
return util.exec(cmd, { cwd = worktree })
end
---@type table<string, integer> -- worktree -> max_count
local max_counts = {}
---@param buf integer
---@param r ow.Git.Repo
local function populate(buf, r)
local state = r:state(buf)
if not state then
return
end
local stdout = fetch(r.worktree, state.log_max_count)
local stdout = fetch(r.worktree, max_counts[r.worktree])
if not stdout then
return
end
@@ -123,10 +122,8 @@ function M.open(opts)
return
end
max_counts[r.worktree] = opts.max_count
local buf = vim.fn.bufadd(M.URI_PREFIX .. r.worktree)
repo.bind(buf, r)
local state = r:state(buf) --[[@as -nil]]
state.log_max_count = opts.max_count
local was_loaded = vim.api.nvim_buf_is_loaded(buf)
local win = vim.fn.bufwinid(buf)
+2 -3
View File
@@ -375,13 +375,12 @@ end
---@return boolean dispatched
function M.open_under_cursor()
local s = repo.state()
if not s then
local r = repo.resolve()
if not r then
return false
end
local line = vim.api.nvim_get_current_line()
local r = s.repo
local sha = line:match("^commit (%x+)$")
or line:match("^parent (%x+)$")
-1
View File
@@ -19,7 +19,6 @@ end
---@field immutable boolean?
---@field index_writer boolean?
---@field index_mode string?
---@field log_max_count integer?
---@alias ow.Git.Repo.Event "refresh"