Skip to content

Commit 4307dea

Browse files
committed
Fix CR suggestions
1 parent 7c74656 commit 4307dea

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

lua/kickstart/plugins/debug.lua

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,12 @@ return {
4343
local function find_bp()
4444
local buf_bps = require('dap.breakpoints').get(vim.fn.bufnr())[vim.fn.bufnr()]
4545
---@type dap.SourceBreakpoint
46-
local bp = { condition = '', logMessage = '', hitCondition = '', line = vim.fn.line '.' }
4746
for _, candidate in ipairs(buf_bps) do
4847
if candidate.line and candidate.line == vim.fn.line '.' then
49-
bp = candidate
50-
break
48+
return candidate
5149
end
5250
end
53-
return bp
51+
return { condition = '', logMessage = '', hitCondition = '', line = vim.fn.line '.' }
5452
end
5553

5654
-- Elicit customization via a UI prompt
@@ -77,16 +75,23 @@ return {
7775
},
7876
}
7977
local menu_options = {}
80-
for k, v in pairs(props) do
81-
table.insert(menu_options, ('%s: %s'):format(k, v.value))
78+
for k, _ in pairs(props) do
79+
table.insert(menu_options, k)
8280
end
8381
vim.ui.select(menu_options, {
8482
prompt = 'Edit Breakpoint',
83+
format_item = function(item)
84+
return ('%s: %s'):format(item, props[item].value)
85+
end,
8586
}, function(choice)
86-
local prompt = (tostring(choice)):gsub(':.*', '')
87-
props[prompt].setter(vim.fn.input {
88-
prompt = ('[%s] '):format(prompt),
89-
default = props[prompt].value,
87+
if choice == nil then
88+
-- User cancelled the selection
89+
return
90+
end
91+
92+
props[choice].setter(vim.fn.input {
93+
prompt = ('[%s] '):format(choice),
94+
default = props[choice].value,
9095
})
9196

9297
-- Set breakpoint for current line, with customizations (see h:dap.set_breakpoint())

0 commit comments

Comments
 (0)