Skip to content
Open
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
3 changes: 2 additions & 1 deletion lua/flutter-tools/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ local function set_current_device(device)
end

---Resolve the device name from the `Launching ... on <device> in <mode> mode` output line
---@param line string
---@param line string|nil
local function update_device_from_output(line)
if not line then return end
local name = line:match("^Launching .+ on (.+) in %w+ mode")
if not name then return end
local device = vim.tbl_extend("force", current_device or {}, { name = vim.trim(name) })
Expand Down
4 changes: 4 additions & 0 deletions tests/commands_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ describe("commands", function()
assert.is_nil(commands.current_device())
end)

it("should not crash when output line is nil", function()
assert.has_no.errors(function() commands.__update_device_from_output(nil) end)
end)

it("should batch consecutive error lines into one notification", function()
local config = require("flutter-tools.config")
local ui = require("flutter-tools.ui")
Expand Down