@@ -36,8 +36,9 @@ return {
3636 {
3737 ' <leader>B' ,
3838 function ()
39+ require ' dap.protocol'
3940 local dap = require ' dap'
40- -- Search for an existing breakpoing on this line in this buffer
41+ -- Search for an existing breakpoint on this line in this buffer
4142 --- @return dap.SourceBreakpoint bp that was either found , or an empty placeholder
4243 local function find_bp ()
4344 local buf_bps = require (' dap.breakpoints' ).get (vim .fn .bufnr ())[vim .fn .bufnr ()]
@@ -55,30 +56,38 @@ return {
5556 -- Elicit customization via a UI prompt
5657 --- @param bp dap.SourceBreakpoint a breakpoint
5758 local function customize_bp (bp )
58- local fields = {
59- (' Condition: (%s)\n ' ):format (bp .condition ),
60- (' Hit Condition: (%s)\n ' ):format (bp .hitCondition ),
61- (' Log Message: (%s)\n ' ):format (bp .logMessage ),
59+ local props = {
60+ [' Condition' ] = {
61+ value = bp .condition ,
62+ setter = function (v )
63+ bp .condition = v
64+ end ,
65+ },
66+ [' Hit Condition' ] = {
67+ value = bp .hitCondition ,
68+ setter = function (v )
69+ bp .hitCondition = v
70+ end ,
71+ },
72+ [' Log Message' ] = {
73+ value = bp .logMessage ,
74+ setter = function (v )
75+ bp .logMessage = v
76+ end ,
77+ },
6278 }
63- vim .ui .select (fields , {
64- prompt = ' Edit breakpoint' ,
79+ local menu_options = {}
80+ for k , v in pairs (props ) do
81+ table.insert (menu_options , (' %s: %s' ):format (k , v .value ))
82+ end
83+ vim .ui .select (menu_options , {
84+ prompt = ' Edit Breakpoint' ,
6585 }, function (choice )
66- if choice == fields [1 ] then
67- bp .condition = vim .fn .input {
68- prompt = ' Condition: ' ,
69- default = bp .condition ,
70- }
71- elseif choice == fields [2 ] then
72- bp .hitCondition = vim .fn .input {
73- prompt = ' Hit Condition: ' ,
74- default = bp .hitCondition ,
75- }
76- elseif choice == fields [3 ] then
77- bp .logMessage = vim .fn .input {
78- prompt = ' Log Message: ' ,
79- default = bp .logMessage ,
80- }
81- end
86+ local prompt = (tostring (choice )):gsub (' :.*' , ' ' )
87+ props [prompt ].setter (vim .fn .input {
88+ prompt = (' [%s] ' ):format (prompt ),
89+ default = props [prompt ].value ,
90+ })
8291
8392 -- Set breakpoint for current line, with customizations (see h:dap.set_breakpoint())
8493 dap .set_breakpoint (bp .condition , bp .hitCondition , bp .logMessage )
0 commit comments