@@ -15,7 +15,7 @@ local parser = lazy.require("flutter-tools.utils.yaml_parser")
1515
1616local M = {}
1717
18- --- @alias RunOpts { cli_args : string[] ?, args : string[] ?, device : Device ?}
18+ --- @alias RunOpts { cli_args : string[] ?, args : string[] ?, device : Device ?, force_debug : boolean ? }
1919
2020--- @type table ?
2121local current_device = nil
@@ -29,11 +29,13 @@ local current_device = nil
2929--- @type flutter.Runner ?
3030local runner = nil
3131
32- local function use_debugger_runner ()
33- if not config .debugger .enabled then return false end
34- local dap_ok , _ = pcall (require , " dap" )
35- if dap_ok then return true end
36- ui .notify (" debugger runner was request but nvim-dap is not installed!" , ui .ERROR )
32+ local function use_debugger_runner (force_debug )
33+ if force_debug or config .debugger .enabled then
34+ local dap_ok , _ = pcall (require , " dap" )
35+ if dap_ok then return true end
36+ ui .notify (" debugger runner was request but nvim-dap is not installed!" , ui .ERROR )
37+ return false
38+ end
3739 return false
3840end
3941
9597--- Take arguments from the commandline and pass
9698--- them to the run command
9799--- @param args string
98- function M .run_command (args )
100+ --- @param force_debug boolean true if the command is a debug command
101+ function M .run_command (args , force_debug )
99102 args = args and args ~= " " and vim .split (args , " " ) or nil
100- M .run ({ args = args })
103+ M .run ({ args = args , force_debug = force_debug })
101104end
102105
103106--- @param callback fun ( project_config : flutter.ProjectConfig ?)
@@ -137,7 +140,7 @@ local function get_run_args(opts, conf)
137140 local dev_url = dev_tools .get_url ()
138141 local additional_args = conf and conf .additional_args
139142
140- if not use_debugger_runner () then vim .list_extend (args , { " run" }) end
143+ if not use_debugger_runner (opts . force_debug ) then vim .list_extend (args , { " run" }) end
141144 if not cmd_args and device then vim .list_extend (args , { " -d" , device }) end
142145 if web_port then vim .list_extend (args , { " --web-port" , web_port }) end
143146 if cmd_args then vim .list_extend (args , cmd_args ) end
@@ -266,7 +269,7 @@ local function run(opts, project_conf)
266269 else
267270 ui .notify (" Starting dart project..." )
268271 end
269- runner = use_debugger_runner () and debugger_runner or job_runner
272+ runner = use_debugger_runner (opts . force_debug ) and debugger_runner or job_runner
270273 runner :run (paths , args , cwd , on_run_data , on_run_exit , is_flutter_project , project_conf )
271274 end )
272275end
0 commit comments