fix: spec list with a single plugin spec ignored (#34)

This commit is contained in:
Marc Jakobi
2024-07-10 22:18:55 +02:00
committed by GitHub
parent 947c01985e
commit e0831fee31
2 changed files with 26 additions and 1 deletions
+9 -1
View File
@@ -151,10 +151,18 @@ local function parse(spec)
return result
end
---XXX: This is unsafe because we assume a prior `vim.islist` check
---
---@param spec lz.n.Spec
---@return boolean
local function is_list_with_single_spec_unsafe(spec)
return #spec == 1 and type(spec[1]) == "table"
end
---@param spec lz.n.Spec
---@return boolean
function M.is_spec_list(spec)
return #spec > 1 or vim.islist(spec) and #spec > 1
return #spec > 1 or vim.islist(spec) and #spec > 1 or is_list_with_single_spec_unsafe(spec)
end
---@param spec lz.n.Spec
+17
View File
@@ -81,5 +81,22 @@ describe("lz.n", function()
vim.api.nvim_feedkeys(feed, "ix", false)
assert.True(loaded)
end)
it("list with a single plugin spec", function()
local spy_load = spy.on(loader, "_load")
lz.load({
{
"single.nvim",
cmd = "Single",
},
})
assert.spy(spy_load).called(0)
pcall(vim.cmd.Single)
assert.spy(spy_load).called(1)
assert.spy(spy_load).called_with({
name = "single.nvim",
lazy = true,
cmd = { "Single" },
})
end)
end)
end)