@@ -53,9 +53,11 @@ describe('dap.ext.vscode', function()
5353 it (' supports pickString input' , function ()
5454 local options
5555 local opts
56+ local label
5657 vim .ui .select = function (options_ , opts_ , on_choice )
5758 options = options_
5859 opts = opts_
60+ label = opts_ .format_item (options_ [1 ])
5961 on_choice (options_ [1 ])
6062 end
6163 local jsonstr = [[
@@ -87,6 +89,7 @@ describe('dap.ext.vscode', function()
8789 end )()
8890 vim .wait (1000 , function () return ok end )
8991 assert .are .same (true , ok , " coroutine must finish" )
92+ assert .are .same (" one" , label )
9093 assert .are .same (" ${workspaceFolder}/one" , result )
9194 assert .are .same (" Select input" , opts .prompt )
9295 assert .are .same ({" one" , " two" , " three" }, options )
@@ -229,4 +232,89 @@ describe('dap.ext.vscode', function()
229232 assert .are .same (" Your input: " , prompt )
230233 assert .are .same (" " , default )
231234 end )
235+
236+ it (' supports pickString with options' , function ()
237+ local opts
238+ local label
239+ vim .ui .select = function (options_ , opts_ , on_choice )
240+ opts = opts_
241+ label = opts_ .format_item (options_ [1 ])
242+ on_choice (options_ [1 ])
243+ end
244+ local jsonstr = [[
245+ {
246+ "configurations": [
247+ {
248+ "type": "dummy",
249+ "request": "launch",
250+ "name": "Dummy",
251+ "program": "${workspaceFolder}/${input:my_input}"
252+ }
253+ ],
254+ "inputs": [
255+ {
256+ "id": "my_input",
257+ "type": "pickString",
258+ "options": [
259+ { "label": "First value", "value": "one" },
260+ { "label": "Second value", "value": "two" }
261+ ],
262+ "description": "Select input"
263+ }
264+ ]
265+ }
266+ ]]
267+ local configs = vscode ._load_json (jsonstr )
268+ local ok = false
269+ local result
270+ coroutine.wrap (function ()
271+ result = configs [1 ].program ()
272+ ok = true
273+ end )()
274+ vim .wait (1000 , function () return ok end )
275+ assert .are .same (true , ok , " coroutine must finish" )
276+ assert .are .same (" ${workspaceFolder}/one" , result )
277+ assert .are .same (" Select input" , opts .prompt )
278+ assert .are .same (" First value" , label )
279+ end )
280+
281+ it (' supports pickString with options, nothing selected' , function ()
282+ vim .ui .select = function (_ , _ , on_choice )
283+ on_choice (nil )
284+ end
285+ local jsonstr = [[
286+ {
287+ "configurations": [
288+ {
289+ "type": "dummy",
290+ "request": "launch",
291+ "name": "Dummy",
292+ "program": "${workspaceFolder}/${input:my_input}"
293+ }
294+ ],
295+ "inputs": [
296+ {
297+ "id": "my_input",
298+ "type": "pickString",
299+ "options": [
300+ { "label": "First value", "value": "one" },
301+ { "label": "Second value", "value": "two" }
302+ ],
303+ "description": "Select input"
304+ }
305+ ]
306+ }
307+ ]]
308+ local configs = vscode ._load_json (jsonstr )
309+ local ok = false
310+ local result
311+ coroutine.wrap (function ()
312+ result = configs [1 ].program ()
313+ ok = true
314+ end )()
315+ vim .wait (1000 , function () return ok end )
316+ assert .are .same (true , ok , " coroutine must finish" )
317+ -- input defaults to ''
318+ assert .are .same (" ${workspaceFolder}/" , result )
319+ end )
232320end )
0 commit comments