@@ -179,6 +179,7 @@ function M:_rebuild(name)
179179 local super = nil
180180 plugin .url = nil
181181 plugin ._ .dep = true
182+ plugin ._ .top = true
182183 plugin .optional = true
183184
184185 assert (# plugin ._ .frags > 0 , " no fragments found for plugin " .. name )
@@ -195,6 +196,7 @@ function M:_rebuild(name)
195196 plugin ._ .dep = plugin ._ .dep and fragment .dep
196197 plugin .optional = plugin .optional and (rawget (fragment .spec , " optional" ) == true )
197198 plugin .url = fragment .url or plugin .url
199+ plugin ._ .top = plugin ._ .top and fragment .pid == nil
198200
199201 -- dependencies
200202 for _ , dep in ipairs (fragment .deps or {}) do
@@ -302,16 +304,26 @@ end
302304--- Removes plugins that are disabled.
303305function M :fix_disabled ()
304306 local changes = 0
305- for _ , plugin in pairs (self .plugins ) do
306- if plugin .enabled == false or (type (plugin .enabled ) == " function" and not plugin .enabled ()) then
307- changes = changes + 1
308- if plugin .optional then
309- self :del (plugin .name )
310- else
311- self :disable (plugin )
307+ local function check (top )
308+ for _ , plugin in pairs (self .plugins ) do
309+ if plugin ._ .top == top then
310+ if plugin .enabled == false or (type (plugin .enabled ) == " function" and not plugin .enabled ()) then
311+ changes = changes + 1
312+ if plugin .optional then
313+ self :del (plugin .name )
314+ else
315+ self :disable (plugin )
316+ end
317+ end
312318 end
313319 end
314320 end
321+ -- disable top-level plugins first, since they may have non-top-level frags
322+ -- that disable other plugins
323+ check (true )
324+ self :rebuild ()
325+ -- then disable non-top-level plugins
326+ check (false )
315327 self :rebuild ()
316328 return changes
317329end
0 commit comments