@@ -64,8 +64,9 @@ return {
6464 {
6565 ' <leader>B' ,
6666 function ()
67+ require ' dap.protocol'
6768 local dap = require ' dap'
68- -- Search for an existing breakpoing on this line in this buffer
69+ -- Search for an existing breakpoint on this line in this buffer
6970 --- @return dap.SourceBreakpoint bp that was either found , or an empty placeholder
7071 local function find_bp ()
7172 local buf_bps = require (' dap.breakpoints' ).get (vim .fn .bufnr ())[vim .fn .bufnr ()]
@@ -83,30 +84,38 @@ return {
8384 -- Elicit customization via a UI prompt
8485 --- @param bp dap.SourceBreakpoint a breakpoint
8586 local function customize_bp (bp )
86- local fields = {
87- (' Condition: (%s)\n ' ):format (bp .condition ),
88- (' Hit Condition: (%s)\n ' ):format (bp .hitCondition ),
89- (' Log Message: (%s)\n ' ):format (bp .logMessage ),
87+ local props = {
88+ [' Condition' ] = {
89+ value = bp .condition ,
90+ setter = function (v )
91+ bp .condition = v
92+ end ,
93+ },
94+ [' Hit Condition' ] = {
95+ value = bp .hitCondition ,
96+ setter = function (v )
97+ bp .hitCondition = v
98+ end ,
99+ },
100+ [' Log Message' ] = {
101+ value = bp .logMessage ,
102+ setter = function (v )
103+ bp .logMessage = v
104+ end ,
105+ },
90106 }
91- vim .ui .select (fields , {
92- prompt = ' Edit breakpoint' ,
107+ local menu_options = {}
108+ for k , v in pairs (props ) do
109+ table.insert (menu_options , (' %s: %s' ):format (k , v .value ))
110+ end
111+ vim .ui .select (menu_options , {
112+ prompt = ' Edit Breakpoint' ,
93113 }, function (choice )
94- if choice == fields [1 ] then
95- bp .condition = vim .fn .input {
96- prompt = ' Condition: ' ,
97- default = bp .condition ,
98- }
99- elseif choice == fields [2 ] then
100- bp .hitCondition = vim .fn .input {
101- prompt = ' Hit Condition: ' ,
102- default = bp .hitCondition ,
103- }
104- elseif choice == fields [3 ] then
105- bp .logMessage = vim .fn .input {
106- prompt = ' Log Message: ' ,
107- default = bp .logMessage ,
108- }
109- end
114+ local prompt = (tostring (choice )):gsub (' :.*' , ' ' )
115+ props [prompt ].setter (vim .fn .input {
116+ prompt = (' [%s] ' ):format (prompt ),
117+ default = props [prompt ].value ,
118+ })
110119
111120 -- Set breakpoint for current line, with customizations (see h:dap.set_breakpoint())
112121 dap .set_breakpoint (bp .condition , bp .hitCondition , bp .logMessage )
0 commit comments