Skip to content

Commit a4fb55f

Browse files
committed
feat: cancel git status update when nvim is closing, part of #333
1 parent 3d66596 commit a4fb55f

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lua/neo-tree/git/status.lua

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,23 @@ M.status_async = function(path, base)
196196
end
197197
end
198198

199-
local wrapped_process_line_staged = vim.schedule_wrap(function(err, line)
199+
local wrapped_process_line_staged = vim.schedule_wrap(function(err, line, job)
200+
if vim.v.dying > 0 or vim.v.exiting ~= vim.NIL then
201+
job:shutdown()
202+
return
203+
end
200204
if err and err > 0 then
201205
log.error("status_async staged error: ", err, line)
202206
else
203207
parse_git_status_line(context, line)
204208
end
205209
end)
206210

207-
local wrapped_process_line_unstaged = vim.schedule_wrap(function(err, line)
211+
local wrapped_process_line_unstaged = vim.schedule_wrap(function(err, line, job)
212+
if vim.v.dying > 0 or vim.v.exiting ~= vim.NIL then
213+
job:shutdown()
214+
return
215+
end
208216
if err and err > 0 then
209217
log.error("status_async unstaged error: ", err, line)
210218
else
@@ -215,7 +223,11 @@ M.status_async = function(path, base)
215223
end
216224
end)
217225

218-
local wrapped_process_line_untracked = vim.schedule_wrap(function(err, line)
226+
local wrapped_process_line_untracked = vim.schedule_wrap(function(err, line, job)
227+
if vim.v.dying > 0 or vim.v.exiting ~= vim.NIL then
228+
job:shutdown()
229+
return
230+
end
219231
if err and err > 0 then
220232
log.error("status_async untracked error: ", err, line)
221233
else

0 commit comments

Comments
 (0)