Skip to content

Commit b2f8b9b

Browse files
Chris--AFederico Fissore
authored and
Federico Fissore
committed
IDE: prevent multiple bad name notifications.
This patch will prevent the IDE from informing the user about a bad sketch folder name multiple times. Now the user is informed once at start up only, or once when it is detected during a rescan of the folders.
1 parent 281fc68 commit b2f8b9b

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndexer.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import java.io.InputStream;
5252
import java.util.Arrays;
5353
import java.util.List;
54+
import java.util.ArrayList;
5455

5556
import static processing.app.I18n._;
5657

@@ -64,6 +65,8 @@ public class LibrariesIndexer {
6465
private final File indexFile;
6566
private final File stagingFolder;
6667
private File sketchbookLibrariesFolder;
68+
69+
private static final List<String> badLibNotified = new ArrayList<String>();
6770

6871
public LibrariesIndexer(File preferencesFolder, ContributionsIndexer contributionsIndexer) {
6972
this.contributionsIndexer = contributionsIndexer;
@@ -135,11 +138,18 @@ private void scanInstalledLibraries(File folder, boolean isSketchbook) {
135138

136139
for (File subfolder : list) {
137140
if (!BaseNoGui.isSanitaryName(subfolder.getName())) {
138-
String mess = I18n.format(_("The library \"{0}\" cannot be used.\n"
141+
142+
// Detect whether the current folder name has already had a notification.
143+
if(!badLibNotified.contains(subfolder.getName())) {
144+
145+
badLibNotified.add(subfolder.getName());
146+
147+
String mess = I18n.format(_("The library \"{0}\" cannot be used.\n"
139148
+ "Library names must contain only basic letters and numbers.\n"
140149
+ "(ASCII only and no spaces, and it cannot start with a number)"),
141150
subfolder.getName());
142-
BaseNoGui.showMessage(_("Ignoring bad library name"), mess);
151+
BaseNoGui.showMessage(_("Ignoring bad library name"), mess);
152+
}
143153
continue;
144154
}
145155

0 commit comments

Comments
 (0)