Skip to content

Commit 11b67da

Browse files
committed
fix: always schedule after git commands
fixes #1425 closes #1460
1 parent ecd3717 commit 11b67da

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

lua/gitsigns/actions/qflist.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ local function buildqflist(target)
8686
obj = ':0:' .. f
8787
end
8888
local a = r:get_show_text(obj)
89-
async.schedule()
9089
local hunks = run_diff(a, util.file_lines(f_abs))
9190
hunks_to_qflist(f_abs, hunks, qflist)
9291
end

lua/gitsigns/actions/show_commit.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ function M.show_commit(base, open, bufnr, ref_list, ref_list_ptr)
110110
table.remove(res, 6)
111111
end
112112

113-
Async.schedule()
114113
local buffer_name = bcache:get_rev_bufname(base, false)
115114
local commit_buf = nil
116115
-- find preexisting commit buffer or create a new one

lua/gitsigns/git/cmd.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ local function git_command(args, spec)
3434

3535
--- @type vim.SystemCompleted
3636
local obj = asystem(cmd, spec)
37+
async.schedule()
3738

3839
if not spec.ignore_error and obj.code > 0 then
3940
log.eprintf(

test/gitsigns_spec.lua

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,35 @@ describe('gitsigns attach', function()
10761076
eq('main', abbrev_head)
10771077
end)
10781078

1079+
it('does not error after git system callbacks (#1425)', function()
1080+
setup_test_repo()
1081+
setup_gitsigns(config)
1082+
1083+
edit(test_file)
1084+
wait_for_attach()
1085+
1086+
local ok = exec_lua(function()
1087+
local async = require('gitsigns.async')
1088+
local git_cmd = require('gitsigns.git.cmd')
1089+
1090+
return async
1091+
.run(function()
1092+
-- `git_cmd()` ultimately uses `vim.system`, whose on_exit callback runs
1093+
-- in fast event context. Ensure we yield to the scheduler after the
1094+
-- command completes so Neovim API calls here don't raise E5560.
1095+
git_cmd({ '--version' }, { text = true })
1096+
1097+
local b = vim.api.nvim_create_buf(false, true)
1098+
vim.bo[b].buftype = 'nofile'
1099+
vim.api.nvim_buf_delete(b, { force = true })
1100+
return true
1101+
end)
1102+
:wait()
1103+
end)
1104+
1105+
eq(true, ok)
1106+
end)
1107+
10791108
it('does not error when attaching to files out of tree (#1297)', function()
10801109
setup_test_repo()
10811110
setup_gitsigns(config)

0 commit comments

Comments
 (0)