@@ -4,6 +4,8 @@ local lazy = require("diffview.lazy")
44local EventName = lazy .access (" diffview.events" , " EventName" ) --- @type EventName | LazyModule
55local RevType = lazy .access (" diffview.vcs.rev" , " RevType" ) --- @type RevType | LazyModule
66local actions = lazy .require (" diffview.actions" ) --- @module " diffview.actions"
7+ local config = lazy .require (" diffview.config" ) --- @module " diffview.config"
8+ local lib = lazy .require (" diffview.lib" ) --- @module " diffview.lib"
79local utils = lazy .require (" diffview.utils" ) --- @module " diffview.utils"
810local vcs_utils = lazy .require (" diffview.vcs.utils" ) --- @module " diffview.vcs.utils"
911
@@ -200,6 +202,13 @@ return function(view)
200202 view :update_files (
201203 vim .schedule_wrap (function ()
202204 view .panel :highlight_cur_file ()
205+ -- Auto-close if all working/conflicting files have been staged.
206+ if config .get_config ().auto_close_on_empty then
207+ if # view .files .working == 0 and # view .files .conflicting == 0 then
208+ view :close ()
209+ lib .dispose_view (view )
210+ end
211+ end
203212 end )
204213 )
205214 view .emitter :emit (EventName .FILES_STAGED , view )
@@ -220,6 +229,13 @@ return function(view)
220229
221230 view :update_files (function ()
222231 view .panel :highlight_cur_file ()
232+ -- Auto-close if all working/conflicting files have been staged.
233+ if config .get_config ().auto_close_on_empty then
234+ if # view .files .working == 0 and # view .files .conflicting == 0 then
235+ view :close ()
236+ lib .dispose_view (view )
237+ end
238+ end
223239 end )
224240 view .emitter :emit (EventName .FILES_STAGED , view )
225241 end
0 commit comments