lazily init empty breakpoint

Instead of creating an empty object to fill, only create one if no match is found.

Co-authored-by: Ori Perry <48057913+oriori1703@users.noreply.github.com>
pull/1534/head
Brian Lehrer 6 days ago committed by GitHub
parent 8bd125f45a
commit 9a66c74623
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -66,21 +66,22 @@ return {
function()
require 'dap.protocol'
local dap = require 'dap'
-- Search for an existing breakpoint on this line in this buffer
---@return dap.SourceBreakpoint bp that was either found, or an empty placeholder
local function find_bp()
local buf_bps = require('dap.breakpoints').get(vim.fn.bufnr())[vim.fn.bufnr()]
---@type dap.SourceBreakpoint
local bp = { condition = '', logMessage = '', hitCondition = '', line = vim.fn.line '.' }
for _, candidate in ipairs(buf_bps) do
if candidate.line and candidate.line == vim.fn.line '.' then
bp = candidate
break
return candidate
end
end
return bp
return { condition = '', logMessage = '', hitCondition = '', line = vim.fn.line '.' }
end
-- Elicit customization via a UI prompt
---@param bp dap.SourceBreakpoint a breakpoint
local function customize_bp(bp)

Loading…
Cancel
Save