Minimize DocSettings:open() calls (#11437)

This commit is contained in:
hius07
2024-02-07 10:35:52 +02:00
committed by GitHub
parent c3bb2263b7
commit b8090c641c
8 changed files with 151 additions and 97 deletions

View File

@@ -86,14 +86,15 @@ end
--- Returns the preferred registered document handler or fallback provider.
-- @string file
-- @bool include_aux include auxiliary (non-document) providers
-- @treturn table provider
function DocumentRegistry:getProvider(file)
function DocumentRegistry:getProvider(file, include_aux)
local providers = self:getProviders(file)
if providers then
if providers or include_aux then
-- associated provider
local provider_key = DocumentRegistry:getAssociatedProviderKey(file)
local provider = provider_key and self.known_providers[provider_key]
if provider and not provider.order then -- excluding auxiliary
if provider and (not provider.order or include_aux) then -- excluding auxiliary by default
return provider
end
-- highest weighted provider