fix(git): close commit proxy window when buffer outlives editor

This commit is contained in:
2026-04-27 17:44:13 +02:00
parent 068db538ca
commit ec61dd57ed
+6 -2
View File
@@ -19,7 +19,7 @@ function M.commit(opts)
table.insert(cmd, "--amend")
end
local proxy_buf
local proxy_buf, proxy_win
editor.run(cmd, { cwd = worktree }, function(file_path, done)
local lines = {}
local f = io.open(file_path, "r")
@@ -30,8 +30,9 @@ function M.commit(opts)
f:close()
end
local buf = git.new_scratch({ name = file_path })
local buf, win = git.new_scratch({ name = file_path })
proxy_buf = buf
proxy_win = win
vim.bo[buf].buftype = "acwrite"
vim.bo[buf].bufhidden = "wipe"
vim.bo[buf].modifiable = true
@@ -63,6 +64,9 @@ function M.commit(opts)
if proxy_buf and vim.api.nvim_buf_is_valid(proxy_buf) then
vim.api.nvim_buf_delete(proxy_buf, { force = true })
end
if proxy_win and vim.api.nvim_win_is_valid(proxy_win) then
vim.api.nvim_win_close(proxy_win, true)
end
if result.code ~= 0 then
log.error("git commit failed: %s", vim.trim(result.stderr or ""))
return