mirror of
https://github.com/dense-analysis/ale.git
synced 2026-06-16 04:26:27 +08:00
#5062 Purge all deeply nested invalid Lua keys
This commit is contained in:
@@ -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 = {}
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user