Skip to content

Commit ca7e678

Browse files
authored
fix(dap): validate custom DAP client configs (#670)
1 parent aed4dab commit ca7e678

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lua/rustaceanvim/dap.lua

+14
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,20 @@ function M.start(args, verbose, callback, on_error)
368368
local final_config = local_config ~= false and vim.deepcopy(local_config) or vim.deepcopy(dap_config)
369369
--- @cast final_config rustaceanvim.dap.client.Config
370370

371+
local err
372+
ok, err = pcall(vim.validate, {
373+
type = { final_config.type, 'string' },
374+
name = { final_config.name, 'string' },
375+
request = { final_config.request, 'string' },
376+
})
377+
if not ok then
378+
on_error(([[
379+
DAP client config validation failed.
380+
%s
381+
If you have specified a custom configuration, see ":h rustaceanvim.dap.client.Config".
382+
]]):format(err))
383+
return
384+
end
371385
if dap.adapters[final_config.type] == nil then
372386
on_error('No adapter exists named "' .. final_config.type .. '". See ":h dap-adapter" for more information')
373387
return

0 commit comments

Comments
 (0)