Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cec4f41

Browse files
facchinmcmaglie
authored andcommitted
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)
1 parent 96bd671 commit cec4f41

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

‎app/src/cc/arduino/contributions/packages/ui/ContributedPlatformReleases.java‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ public boolean shouldContain(ContributedPlatform platform) {
6161
return platform.getArchitecture().equals(arch);
6262
}
6363

64+
public boolean contains(ContributedPlatform platform) {
65+
return (platform.getParentPackage().equals(packager)
66+
&& platform.getArchitecture().equals(arch)
67+
&& versions.contains(platform.getParsedVersion()));
68+
}
69+
6470
public void add(ContributedPlatform platform) {
6571
releases.add(platform);
6672
String version = platform.getParsedVersion();

‎app/src/cc/arduino/contributions/packages/ui/ContributionIndexTableModel.java‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,21 @@ private void updateContributions() {
6666
+ platform.getBoards().stream()
6767
.map(ContributedBoard::getName)
6868
.collect(Collectors.joining(" "));
69+
70+
// Add all the versions of the same core, even if there's no match
71+
for (ContributedPlatformReleases contribution : contributions) {
72+
if (contribution.shouldContain(platform)) {
73+
addContribution(platform);
74+
continue;
75+
}
76+
}
77+
6978
if (!filter.test(platform)) {
7079
continue;
7180
}
7281
if (!stringContainsAll(compoundTargetSearchText, filters))
7382
continue;
83+
7484
addContribution(platform);
7585
}
7686
}
@@ -110,12 +120,16 @@ private boolean stringContainsAll(String string, String set[]) {
110120

111121
private void addContribution(ContributedPlatform platform) {
112122
for (ContributedPlatformReleases contribution : contributions) {
113-
if (!contribution.shouldContain(platform))
123+
if (!contribution.shouldContain(platform)) {
114124
continue;
125+
}
126+
if (contribution.contains(platform)) {
127+
// no duplicates
128+
return;
129+
}
115130
contribution.add(platform);
116131
return;
117132
}
118-
119133
contributions.add(new ContributedPlatformReleases(platform));
120134
}
121135

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /