fix(git): preserve dispatch and content after jumping back
This commit is contained in:
@@ -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
@@ -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+)$")
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user