Skip to content

Commit 9a66c74

Browse files
blehreroriori1703
andauthored
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 <[email protected]>
1 parent 8bd125f commit 9a66c74

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
@@ -66,21 +66,22 @@ return {
6666
function()
6767
require 'dap.protocol'
6868
local dap = require 'dap'
69+
6970
-- Search for an existing breakpoint on this line in this buffer
7071
---@return dap.SourceBreakpoint bp that was either found, or an empty placeholder
7172
local function find_bp()
7273
local buf_bps = require('dap.breakpoints').get(vim.fn.bufnr())[vim.fn.bufnr()]
7374
---@type dap.SourceBreakpoint
74-
local bp = { condition = '', logMessage = '', hitCondition = '', line = vim.fn.line '.' }
7575
for _, candidate in ipairs(buf_bps) do
7676
if candidate.line and candidate.line == vim.fn.line '.' then
77-
bp = candidate
78-
break
77+
return candidate
7978
end
8079
end
81-
return bp
80+
81+
return { condition = '', logMessage = '', hitCondition = '', line = vim.fn.line '.' }
8282
end
8383

84+
8485
-- Elicit customization via a UI prompt
8586
---@param bp dap.SourceBreakpoint a breakpoint
8687
local function customize_bp(bp)

0 commit comments

Comments
 (0)