Skip to content

Commit fac4966

Browse files
blehreroriori1703
andcommitted
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>
1 parent 1d00e3f commit fac4966

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lua/kickstart/plugins/debug.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,22 @@ return {
3838
function()
3939
require 'dap.protocol'
4040
local dap = require 'dap'
41+
4142
-- Search for an existing breakpoint on this line in this buffer
4243
---@return dap.SourceBreakpoint bp that was either found, or an empty placeholder
4344
local function find_bp()
4445
local buf_bps = require('dap.breakpoints').get(vim.fn.bufnr())[vim.fn.bufnr()]
4546
---@type dap.SourceBreakpoint
46-
local bp = { condition = '', logMessage = '', hitCondition = '', line = vim.fn.line '.' }
4747
for _, candidate in ipairs(buf_bps) do
4848
if candidate.line and candidate.line == vim.fn.line '.' then
49-
bp = candidate
50-
break
49+
return candidate
5150
end
5251
end
53-
return bp
52+
53+
return { condition = '', logMessage = '', hitCondition = '', line = vim.fn.line '.' }
5454
end
5555

56+
5657
-- Elicit customization via a UI prompt
5758
---@param bp dap.SourceBreakpoint a breakpoint
5859
local function customize_bp(bp)

0 commit comments

Comments
 (0)