1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-11-28 09:24:14 +01:00

Board Manager: searching returns also near matches

The original filter would only populate the contribution list with perfect matches.

Previously, if a core was installed but didn't match the search it wouldn't appear in the results (due to a board being added or the description changed);
the user could then install (not upgrade) the core, triggering a confusing situation.

When moving to arduino-cli backend we should take care of this issue, at least visually (the cli logic would correctly update/downgrade the core)
This commit is contained in:
Martino Facchin 2020-12-22 11:56:52 +01:00 committed by Cristian Maglie
parent 96bd671c6e
commit cec4f41dd7
2 changed files with 22 additions and 2 deletions

View File

@ -61,6 +61,12 @@ public class ContributedPlatformReleases {
return platform.getArchitecture().equals(arch);
}
public boolean contains(ContributedPlatform platform) {
return (platform.getParentPackage().equals(packager)
&& platform.getArchitecture().equals(arch)
&& versions.contains(platform.getParsedVersion()));
}
public void add(ContributedPlatform platform) {
releases.add(platform);
String version = platform.getParsedVersion();

View File

@ -66,11 +66,21 @@ public class ContributionIndexTableModel
+ platform.getBoards().stream()
.map(ContributedBoard::getName)
.collect(Collectors.joining(" "));
// Add all the versions of the same core, even if there's no match
for (ContributedPlatformReleases contribution : contributions) {
if (contribution.shouldContain(platform)) {
addContribution(platform);
continue;
}
}
if (!filter.test(platform)) {
continue;
}
if (!stringContainsAll(compoundTargetSearchText, filters))
continue;
addContribution(platform);
}
}
@ -110,12 +120,16 @@ public class ContributionIndexTableModel
private void addContribution(ContributedPlatform platform) {
for (ContributedPlatformReleases contribution : contributions) {
if (!contribution.shouldContain(platform))
if (!contribution.shouldContain(platform)) {
continue;
}
if (contribution.contains(platform)) {
// no duplicates
return;
}
contribution.add(platform);
return;
}
contributions.add(new ContributedPlatformReleases(platform));
}