Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions lua/flutter-tools/devices.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local commands = lazy.require("flutter-tools.commands") ---@module "flutter-tool
local executable = lazy.require("flutter-tools.executable") ---@module "flutter-tools.executable"
local fmt = string.format

---@alias Device {name: string, id: string, platform: string, system: string, type: integer}
---@alias Device {name: string, id: string, platform: string, system: string, type: integer, cold_boot: boolean}

local M = {
---@type Job
Expand All @@ -22,7 +22,14 @@ local function get_devices(result, type)
local devices = {}
for _, line in pairs(result) do
local device = M.parse(line, type)
if device then table.insert(devices, device) end
if device then
table.insert(devices, device)
if type == EMULATOR and device.system and device.system == "android" then
local cold_boot_device = vim.tbl_extend("force", {}, device, { cold_boot = true })
cold_boot_device.name = fmt("%s (cold boot)", device.name)
table.insert(devices, cold_boot_device)
end
end
end
return devices
end
Expand Down Expand Up @@ -97,7 +104,9 @@ end
function M.launch_emulator(emulator)
if not emulator then return end
executable.flutter(function(cmd)
M.emulator_job = Job:new({ command = cmd, args = { "emulators", "--launch", emulator.id } })
args = { "emulator", "--launch", emulator.id }
if emulator.cold_boot then table.insert(args, "--cold") end
M.emulator_job = Job:new({ command = cmd, args = args })
M.emulator_job:after_success(vim.schedule_wrap(handle_launch))
M.emulator_job:start()
end)
Expand Down
10 changes: 10 additions & 0 deletions tests/devices_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,15 @@ describe("Devices - ", function()
assert.equal(output.platform, "")
assert.equal(output.system, "android")
end)

it("should skip `crashdata` lines", function()
local output = parse(
[[INFO | Storing crashdata in: /tmp/android-ts/emu-crash-34.2.14.db, detection is enabled for process: 46675 •
INFO | Storing crashdata in: /tmp/android-ts/emu-crash-34.2.14.db, detection is enabled for process: 46675 •
• android]],
1
)
assert.is_nil(output)
end)
end)
end)
Loading