fix 'bug: custom vendor configuration is broken (#1089)' (#1090)

Assigning M.vendors to an empty table {} at line 267 causes the metatable set for M at line 340 to lose its effect. As a result, accessing M.vendors does not retrieve the correct vendors from the configuration but instead always accesses an empty table.
This commit is contained in:
阿楠 2025-01-16 16:56:57 +08:00 committed by GitHub
parent d135cfa270
commit 1660ca5c51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -263,9 +263,6 @@ M.diff = {}
---@type Provider[]
M.providers = {}
---@type AvanteProvider[]
M.vendors = {}
---@param opts? avante.Config
function M.setup(opts)
vim.validate({ opts = { opts, "table", true } })
@ -357,7 +354,7 @@ M.has_provider = function(provider) return M._options[provider] ~= nil or M.vend
M.get_provider = function(provider)
if M._options[provider] ~= nil then
return vim.deepcopy(M._options[provider], true)
elseif M.vendors[provider] ~= nil then
elseif M.vendors and M.vendors[provider] ~= nil then
return vim.deepcopy(M.vendors[provider], true)
else
error("Failed to find provider: " .. provider, 2)