diff --git a/lua/git/commit.lua b/lua/git/commit.lua index d075791..c9fc87e 100644 --- a/lua/git/commit.lua +++ b/lua/git/commit.lua @@ -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