File tree Expand file tree Collapse file tree 3 files changed +43
-3
lines changed
Expand file tree Collapse file tree 3 files changed +43
-3
lines changed Original file line number Diff line number Diff line change @@ -341,7 +341,7 @@ They are declared in an "inputs" array and each input must have the following pr
341341- "id": the identifier of an input
342342- "type": Either `pickString` or `promptString`
343343- "description": Descriptive text shown to the user
344- - "default": Default value
344+ - "default": Default value (Defaults to '' if not provided)
345345
346346`pickString` has an additional "options" property, which is an array of strings.
347347These are shown to the user as options.
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ local function create_input(type_, input)
1212 if not vim .endswith (description , ' : ' ) then
1313 description = description .. ' : '
1414 end
15- return vim .fn .input (description , input .default )
15+ return vim .fn .input (description , input .default or ' ' )
1616 end
1717 elseif type_ == " pickString" then
1818 return function ()
@@ -23,7 +23,7 @@ local function create_input(type_, input)
2323 local co = coroutine.running ()
2424 vim .ui .select (options , opts , function (option )
2525 vim .schedule (function ()
26- coroutine.resume (co , option or input .default )
26+ coroutine.resume (co , option or input .default or ' ' )
2727 end )
2828 end )
2929 return coroutine.yield ()
Original file line number Diff line number Diff line change @@ -189,4 +189,44 @@ describe('dap.ext.vscode', function()
189189 assert .are .same (" bar" , config .foo )
190190 end
191191 end )
192+
193+ it (' supports promptString without default value' , function ()
194+ local prompt
195+ local default
196+ vim .fn .input = function (prompt_ , default_ , _ )
197+ prompt = prompt_
198+ default = default_
199+ return ' Fake input'
200+ end
201+ local jsonstr = [[
202+ {
203+ "configurations": [
204+ {
205+ "type": "dummy",
206+ "request": "launch",
207+ "name": "Dummy",
208+ "program": "${workspaceFolder}/${input:myInput}"
209+ }
210+ ],
211+ "inputs": [
212+ {
213+ "id": "myInput",
214+ "type": "promptString",
215+ "description": "Your input"
216+ }
217+ ]
218+ }
219+ ]]
220+ local configs = vscode ._load_json (jsonstr )
221+ local ok = false
222+ local result
223+ coroutine.wrap (function ()
224+ result = configs [1 ].program ()
225+ ok = true
226+ end )()
227+ vim .wait (1000 , function () return ok end )
228+ assert .are .same (" ${workspaceFolder}/Fake input" , result )
229+ assert .are .same (" Your input: " , prompt )
230+ assert .are .same (" " , default )
231+ end )
192232end )
You can’t perform that action at this time.
0 commit comments