#5062 Purge all deeply nested invalid Lua keys

This commit is contained in:
w0rp
2026-05-31 17:55:04 +01:00
parent 399c0ffd64
commit 7a7fc85e51
3 changed files with 117 additions and 9 deletions
+47
View File
@@ -76,6 +76,53 @@ describe("ale.lsp.send_message", function()
eq({}, vim_fn_calls)
end)
it("should remove Boolean table keys before sending notifications", function()
local notify_calls = {}
clients[1] = {
notify = function(...)
table.insert(notify_calls, {...})
return true
end,
}
eq(-1, lsp.send_message({
client_id = 1,
is_notification = true,
method = "workspace/didChangeConfiguration",
params = {
settings = {
[true] = "invalid",
python = {
analysis = true,
typeCheckingMode = "basic",
[false] = "invalid",
},
array = {
{
enabled = false,
[true] = "invalid",
},
},
},
},
}))
eq(1, #notify_calls)
eq({
settings = {
python = {
analysis = true,
typeCheckingMode = "basic",
},
array = {
{
enabled = false,
},
},
},
}, notify_calls[1][3])
end)
it("should return 0 if a notification fails for Neovim 0.11+", function()
local notify_calls = {}
+37
View File
@@ -153,6 +153,43 @@ describe("ale.lsp.start", function()
eq({foo = "bar", nested = {baz = 123}}, start_calls[1][1].init_options)
end)
it("should remove nested Boolean keys from init_options", function()
lsp.start({
name = "gopls:/code",
cmd = "gopls",
root_dir = "/code",
init_options = {
settings = {
[true] = "invalid",
gopls = {
analyses = {
unusedparams = true,
[false] = "invalid",
},
},
},
},
})
-- Remove functions we can't compare
for _, args in pairs(start_calls) do
args[1].handlers = nil
args[1].on_init = nil
args[1].get_language_id = nil
end
eq(1, #start_calls)
eq({
settings = {
gopls = {
analyses = {
unusedparams = true,
},
},
},
}, start_calls[1][1].init_options)
end)
it("should start lsp socket connections with the correct arguments", function()
lsp.start({
name = "localhost:1234:/code",