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:
parent
96bd671c6e
commit
cec4f41dd7
@ -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();
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user