File tree Expand file tree Collapse file tree
lua/diffview/scene/views/diff Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -326,10 +326,16 @@ DiffView.update_files = debounce.debounce_trailing(
326326 --- @param self DiffView
327327 --- @param callback fun ( err ?: string[] )
328328 async .wrap (function (self , callback )
329+ -- Never update if the view is closing (prevents coroutine failure from race conditions).
330+ if self .closing :check () then
331+ callback ({ " The update was cancelled." })
332+ return
333+ end
334+
329335 await (async .scheduler ())
330336
331337 -- Never update unless the view is in focus
332- if self .tabpage ~= api .nvim_get_current_tabpage () then
338+ if self .closing : check () or self . tabpage ~= api .nvim_get_current_tabpage () then
333339 callback ({ " The update was cancelled." })
334340 return
335341 end
@@ -363,8 +369,8 @@ DiffView.update_files = debounce.debounce_trailing(
363369 return
364370 end
365371
366- -- Stop the update if the view is no longer in focus.
367- if self .tabpage ~= api .nvim_get_current_tabpage () then
372+ -- Stop the update if the view is closing or no longer in focus.
373+ if self .closing : check () or self . tabpage ~= api .nvim_get_current_tabpage () then
368374 callback ({ " The update was cancelled." })
369375 return
370376 end
You can’t perform that action at this time.
0 commit comments