refactor(git): pull buffer-placement tail into util.place_buf

This commit is contained in:
2026-04-29 10:06:08 +02:00
parent 9d938b228b
commit 7bf15a246a
2 changed files with 21 additions and 25 deletions
+2 -17
View File
@@ -286,15 +286,7 @@ local function open_uri(worktree, uri, sha, opts, default_ft)
if default_ft and vim.bo[buf].filetype == "" then
vim.bo[buf].filetype = default_ft
end
local split = opts and opts.split
if split == false then
vim.cmd.normal({ "m'", bang = true })
vim.api.nvim_set_current_buf(buf)
return
end
vim.api.nvim_open_win(buf, true, {
split = split or (vim.o.splitbelow and "below" or "above"),
})
util.place_buf(buf, opts and opts.split)
end
---Open a commit's body via `git cat-file -p` for the header (raw object
@@ -313,14 +305,7 @@ function M.open_commit(worktree, ref, opts)
local name = util.uri(sha)
local existing = vim.fn.bufnr(name)
if existing ~= -1 and vim.api.nvim_buf_is_loaded(existing) then
if split == false then
vim.cmd.normal({ "m'", bang = true })
vim.api.nvim_set_current_buf(existing)
else
vim.api.nvim_open_win(existing, true, {
split = split or (vim.o.splitbelow and "below" or "above"),
})
end
util.place_buf(existing, split)
return
end