Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(editor): error on empty runners with configuration #182

Merged
merged 2 commits into from
Apr 22, 2023
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
21 changes: 18 additions & 3 deletions lua/xbase/pickers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,29 @@ local get_selections = function(root, picker)
for _, command in ipairs(commands) do
for target, info in pairs(targets) do
for _, configuration in ipairs(info.configurations) do
local devices = state.runners[info.platform]
if include_devices and command == C.Run and not (devices == nil or #devices == 0) then
local available_devices = state.runners[info.platform]
if include_devices and command == C.Run and not (available_devices == nil or #available_devices == 0) then
local dvd = cfg.simctl[info.platform] or {}

local devices = {}
if #dvd ~= 0 then
devices = vim.tbl_filter(function(mem)
return vim.tbl_contains(dvd, mem.name)
end, devices)
end, available_devices)
if #devices == 0 then
error(
string.format(
"No runners available based on user config. config: %s, available: %s",
table.concat(dvd, ","),
table.concat(
vim.tbl_map(function(d)
return d.name
end, available_devices),
","
)
)
)
end
end

for _, device in ipairs(devices) do
Expand Down
10 changes: 7 additions & 3 deletions vscode/xbase/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function getPickerItems(
};

if (runners) {
let platformRunners = runners;
let platformRunners: DeviceLookup[] = [];
let platformDevices: string[];

switch (platform) {
Expand All @@ -83,11 +83,15 @@ function getPickerItems(
}

if (platformDevices.length !== 0) {
platformRunners = platformRunners.filter(device => {
platformRunners = runners.filter(device => {
return platformDevices.includes(device.name);
});
if (platformRunners.length == 0) {
const configuredDevicesNames = platformDevices.join(", ");
const avaliableDeviceNames = runners.map(v => v.name).join(", ");
console.error(`No runners available based on user config. config: ${configuredDevicesNames}, available: ${avaliableDeviceNames}`);
}
}
console.log(platformRunners);

platformRunners.forEach(device => {
console.log(device);
Expand Down