@@ -22,7 +22,7 @@ local current_device = nil
22
22
23
23
--- @class flutter.Runner
24
24
--- @field is_running fun ( runner : flutter.Runner ): boolean
25
- --- @field run fun ( runner : flutter.Runner , paths : table , args : table , cwd : string , on_run_data : fun ( is_err : boolean , data : string ), on_run_exit : fun ( data : string[] , args : table , project_conf : flutter.ProjectConfig ?), is_flutter_project : boolean , project_conf : flutter.ProjectConfig ?)
25
+ --- @field run fun ( runner : flutter.Runner , paths : table , args : table , cwd : string , on_run_data : fun ( is_err : boolean , data : string ), on_run_exit : fun ( data : string[] , args : table , project_conf : flutter.ProjectConfig ?, launch_config : dap.Configuration ? ), is_flutter_project : boolean , project_conf : flutter.ProjectConfig ?, launch_config : dap.Configuration ?)
26
26
--- @field cleanup fun ( funner : flutter.Runner )
27
27
--- @field send fun ( runner : flutter.Runner , cmd : string , quiet : boolean ?)
28
28
83
83
--- @param result string[]
84
84
--- @param cli_args string[]
85
85
--- @param project_config flutter.ProjectConfig ?
86
- local function on_run_exit (result , cli_args , project_config )
86
+ --- @param launch_config dap.Configuration ?
87
+ local function on_run_exit (result , cli_args , project_config , launch_config )
87
88
local matched_error , msg = has_recoverable_error (result )
88
89
if matched_error then
89
90
local lines = devices .to_selection_entries (result )
90
91
ui .select ({
91
92
title = (" Flutter run (%s)" ):format (msg ),
92
93
lines = lines ,
93
- on_select = function (device ) devices .select_device (device , cli_args , project_config ) end ,
94
+ on_select = function (device )
95
+ vim .list_extend (cli_args , { " -d" , device .id })
96
+ if launch_config then vim .list_extend (launch_config .args , { " -d" , device .id }) end
97
+ M .run ({ cli_args = cli_args }, project_config , launch_config )
98
+ end ,
94
99
})
95
100
end
96
101
shutdown ()
245
250
246
251
--- @param opts RunOpts
247
252
--- @param project_conf flutter.ProjectConfig ?
248
- local function run (opts , project_conf )
253
+ --- @param launch_config dap.Configuration ?
254
+ local function run (opts , project_conf , launch_config )
249
255
opts = opts or {}
250
256
executable .get (function (paths )
251
257
local args = opts .cli_args or get_run_args (opts , project_conf )
@@ -272,19 +278,31 @@ local function run(opts, project_conf)
272
278
ui .notify (" Starting dart project..." )
273
279
end
274
280
runner = use_debugger_runner (opts .force_debug ) and debugger_runner or job_runner
275
- runner :run (paths , args , cwd , on_run_data , on_run_exit , is_flutter_project , project_conf )
281
+ runner :run (
282
+ paths ,
283
+ args ,
284
+ cwd ,
285
+ on_run_data ,
286
+ on_run_exit ,
287
+ is_flutter_project ,
288
+ project_conf ,
289
+ launch_config
290
+ )
276
291
end )
277
292
end
278
293
279
294
--- Run the flutter application
280
295
--- @param opts RunOpts
281
296
--- @param project_conf flutter.ProjectConfig ?
282
- function M .run (opts , project_conf )
297
+ --- @param launch_config dap.Configuration ?
298
+ function M .run (opts , project_conf , launch_config )
283
299
if M .is_running () then return ui .notify (" Flutter is already running!" ) end
284
300
if project_conf then
285
- run (opts , project_conf )
301
+ run (opts , project_conf , launch_config )
286
302
else
287
- select_project_config (function (selected_project_conf ) run (opts , selected_project_conf ) end )
303
+ select_project_config (
304
+ function (selected_project_conf ) run (opts , selected_project_conf , launch_config ) end
305
+ )
288
306
end
289
307
end
290
308
0 commit comments