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>
This commit is contained in:
parent
8bd125f45a
commit
9a66c74623
|
@ -66,21 +66,22 @@ return {
|
||||||
function()
|
function()
|
||||||
require 'dap.protocol'
|
require 'dap.protocol'
|
||||||
local dap = require 'dap'
|
local dap = require 'dap'
|
||||||
|
|
||||||
-- Search for an existing breakpoint on this line in this buffer
|
-- Search for an existing breakpoint on this line in this buffer
|
||||||
---@return dap.SourceBreakpoint bp that was either found, or an empty placeholder
|
---@return dap.SourceBreakpoint bp that was either found, or an empty placeholder
|
||||||
local function find_bp()
|
local function find_bp()
|
||||||
local buf_bps = require('dap.breakpoints').get(vim.fn.bufnr())[vim.fn.bufnr()]
|
local buf_bps = require('dap.breakpoints').get(vim.fn.bufnr())[vim.fn.bufnr()]
|
||||||
---@type dap.SourceBreakpoint
|
---@type dap.SourceBreakpoint
|
||||||
local bp = { condition = '', logMessage = '', hitCondition = '', line = vim.fn.line '.' }
|
|
||||||
for _, candidate in ipairs(buf_bps) do
|
for _, candidate in ipairs(buf_bps) do
|
||||||
if candidate.line and candidate.line == vim.fn.line '.' then
|
if candidate.line and candidate.line == vim.fn.line '.' then
|
||||||
bp = candidate
|
return candidate
|
||||||
break
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return bp
|
|
||||||
|
return { condition = '', logMessage = '', hitCondition = '', line = vim.fn.line '.' }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Elicit customization via a UI prompt
|
-- Elicit customization via a UI prompt
|
||||||
---@param bp dap.SourceBreakpoint a breakpoint
|
---@param bp dap.SourceBreakpoint a breakpoint
|
||||||
local function customize_bp(bp)
|
local function customize_bp(bp)
|
||||||
|
|
Loading…
Reference in New Issue