@@ -6,7 +6,7 @@ local commands = lazy.require("flutter-tools.commands") ---@module "flutter-tool
6
6
local executable = lazy .require (" flutter-tools.executable" ) --- @module " flutter-tools.executable"
7
7
local fmt = string.format
8
8
9
- --- @alias Device { name : string , id : string , platform : string , system : string , type : integer }
9
+ --- @alias Device { name : string , id : string , platform : string , system : string , type : integer , cold_boot : boolean }
10
10
11
11
local M = {
12
12
--- @type Job
@@ -22,7 +22,14 @@ local function get_devices(result, type)
22
22
local devices = {}
23
23
for _ , line in pairs (result ) do
24
24
local device = M .parse (line , type )
25
- if device then table.insert (devices , device ) end
25
+ if device then
26
+ table.insert (devices , device )
27
+ if type == EMULATOR and device .system and device .system == " android" then
28
+ local cold_boot_device = vim .tbl_extend (" force" , {}, device , { cold_boot = true })
29
+ cold_boot_device .name = fmt (" %s (cold boot)" , device .name )
30
+ table.insert (devices , cold_boot_device )
31
+ end
32
+ end
26
33
end
27
34
return devices
28
35
end
97
104
function M .launch_emulator (emulator )
98
105
if not emulator then return end
99
106
executable .flutter (function (cmd )
100
- M .emulator_job = Job :new ({ command = cmd , args = { " emulators" , " --launch" , emulator .id } })
107
+ args = { " emulator" , " --launch" , emulator .id }
108
+ if emulator .cold_boot then table.insert (args , " --cold" ) end
109
+ M .emulator_job = Job :new ({ command = cmd , args = args })
101
110
M .emulator_job :after_success (vim .schedule_wrap (handle_launch ))
102
111
M .emulator_job :start ()
103
112
end )
0 commit comments