fix(git): close commit proxy window when buffer outlives editor
This commit is contained in:
+6
-2
@@ -19,7 +19,7 @@ function M.commit(opts)
|
|||||||
table.insert(cmd, "--amend")
|
table.insert(cmd, "--amend")
|
||||||
end
|
end
|
||||||
|
|
||||||
local proxy_buf
|
local proxy_buf, proxy_win
|
||||||
editor.run(cmd, { cwd = worktree }, function(file_path, done)
|
editor.run(cmd, { cwd = worktree }, function(file_path, done)
|
||||||
local lines = {}
|
local lines = {}
|
||||||
local f = io.open(file_path, "r")
|
local f = io.open(file_path, "r")
|
||||||
@@ -30,8 +30,9 @@ function M.commit(opts)
|
|||||||
f:close()
|
f:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
local buf = git.new_scratch({ name = file_path })
|
local buf, win = git.new_scratch({ name = file_path })
|
||||||
proxy_buf = buf
|
proxy_buf = buf
|
||||||
|
proxy_win = win
|
||||||
vim.bo[buf].buftype = "acwrite"
|
vim.bo[buf].buftype = "acwrite"
|
||||||
vim.bo[buf].bufhidden = "wipe"
|
vim.bo[buf].bufhidden = "wipe"
|
||||||
vim.bo[buf].modifiable = true
|
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
|
if proxy_buf and vim.api.nvim_buf_is_valid(proxy_buf) then
|
||||||
vim.api.nvim_buf_delete(proxy_buf, { force = true })
|
vim.api.nvim_buf_delete(proxy_buf, { force = true })
|
||||||
end
|
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
|
if result.code ~= 0 then
|
||||||
log.error("git commit failed: %s", vim.trim(result.stderr or ""))
|
log.error("git commit failed: %s", vim.trim(result.stderr or ""))
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user