mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-16 07:46:32 +00:00
Fixed the Platform
ordering.
We have to pick the installed version first. Otherwise we lose the FQBN of the boards. FBQN is used to check if a board has the corresponding core installed. Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
parent
e79d42d6bd
commit
dd10436051
@ -249,7 +249,35 @@ export class BoardsServiceImpl implements BoardsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We must group the cores by ID, and sort platforms by, first the installed version, then version alphabetical order.
|
||||||
|
// Otherwise we lose the FQBN information.
|
||||||
|
const groupedById: Map<string, Platform[]> = new Map();
|
||||||
for (const platform of resp.getSearchOutputList()) {
|
for (const platform of resp.getSearchOutputList()) {
|
||||||
|
const id = platform.getId();
|
||||||
|
if (groupedById.has(id)) {
|
||||||
|
groupedById.get(id)!.push(platform);
|
||||||
|
} else {
|
||||||
|
groupedById.set(id, [platform]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const installedAwareVersionComparator = (left: Platform, right: Platform) => {
|
||||||
|
// XXX: we cannot rely on `platform.getInstalled()`, it is always an empty string.
|
||||||
|
const leftInstalled = !!installedPlatforms.find(ip => ip.getId() === left.getId() && ip.getInstalled() === left.getLatest());
|
||||||
|
const rightInstalled = !!installedPlatforms.find(ip => ip.getId() === right.getId() && ip.getInstalled() === right.getLatest());
|
||||||
|
if (leftInstalled && !rightInstalled) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (!leftInstalled && rightInstalled) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return Installable.Version.COMPARATOR(right.getLatest(), left.getLatest()); // Higher version comes first.
|
||||||
|
}
|
||||||
|
for (const id of groupedById.keys()) {
|
||||||
|
groupedById.get(id)!.sort(installedAwareVersionComparator);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const id of groupedById.keys()) {
|
||||||
|
for (const platform of groupedById.get(id)!) {
|
||||||
const id = platform.getId();
|
const id = platform.getId();
|
||||||
const pkg = packages.get(id);
|
const pkg = packages.get(id);
|
||||||
if (pkg) {
|
if (pkg) {
|
||||||
@ -259,6 +287,7 @@ export class BoardsServiceImpl implements BoardsService {
|
|||||||
packages.set(id, toPackage(platform));
|
packages.set(id, toPackage(platform));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return { items: [...packages.values()] };
|
return { items: [...packages.values()] };
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user