mirror of
https://github.com/mfussenegger/nvim-dap
synced 2024-09-16 14:24:03 +02:00
Add type annotations for setBreakoints; fix tests on nightly
This commit is contained in:
parent
dcc85d12d6
commit
b84e30402f
4 changed files with 15 additions and 7 deletions
|
@ -60,12 +60,14 @@ function M.update(breakpoint)
|
|||
end
|
||||
|
||||
|
||||
function M.set_state(bufnr, lnum, state)
|
||||
local ok, placements = pcall(vim.fn.sign_getplaced, bufnr, { group = ns; lnum = lnum; })
|
||||
---@param bufnr integer
|
||||
---@param state dap.Breakpoint
|
||||
function M.set_state(bufnr, state)
|
||||
local ok, placements = pcall(vim.fn.sign_getplaced, bufnr, { group = ns; lnum = state.line; })
|
||||
if not ok then
|
||||
return
|
||||
end
|
||||
local signs = placements[1].signs
|
||||
local signs = (placements[1] or {}).signs
|
||||
if not signs or next(signs) == nil then
|
||||
return
|
||||
end
|
||||
|
@ -80,7 +82,7 @@ function M.set_state(bufnr, lnum, state)
|
|||
ns,
|
||||
'DapBreakpointRejected',
|
||||
bufnr,
|
||||
{ lnum = lnum; priority = 21; }
|
||||
{ lnum = state.line; priority = 21; }
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -229,6 +229,8 @@
|
|||
---@field algorithm "MD5"|"SHA1"|"SHA256"|"timestamp"
|
||||
---@field checksum string
|
||||
|
||||
---@class dap.SetBreakpointsResponse
|
||||
---@field breakpoints dap.Breakpoint[]
|
||||
|
||||
---@class dap.Breakpoint
|
||||
---@field id? number
|
||||
|
|
|
@ -894,12 +894,14 @@ do
|
|||
),
|
||||
lines = vim.tbl_map(function(x) return x.line end, buf_bps);
|
||||
}
|
||||
self:request('setBreakpoints', payload, function(err1, resp)
|
||||
---@param err1 dap.ErrorResponse
|
||||
---@param resp dap.SetBreakpointsResponse
|
||||
local function on_response(err1, resp)
|
||||
if err1 then
|
||||
utils.notify('Error setting breakpoints: ' .. utils.fmt_error(err1), vim.log.levels.ERROR)
|
||||
elseif resp then
|
||||
for _, bp in pairs(resp.breakpoints) do
|
||||
breakpoints.set_state(bufnr, bp.line, bp)
|
||||
breakpoints.set_state(bufnr, bp)
|
||||
if not bp.verified then
|
||||
log.info('Breakpoint unverified', bp)
|
||||
end
|
||||
|
@ -909,7 +911,8 @@ do
|
|||
if num_requests == 0 and on_done then
|
||||
on_done()
|
||||
end
|
||||
end)
|
||||
end
|
||||
self:request('setBreakpoints', payload, on_response)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -37,6 +37,7 @@ describe('dap with debugpy', function()
|
|||
}
|
||||
local bp_lnum = 8
|
||||
local bufnr = vim.fn.bufadd(program)
|
||||
vim.fn.bufload(bufnr)
|
||||
breakpoints.set({}, bufnr, bp_lnum)
|
||||
local events = {}
|
||||
local dummy_payload = nil
|
||||
|
|
Loading…
Reference in a new issue