Skip to content

Commit e74c2dc

Browse files
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 fe94d6a commit e74c2dc

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
@@ -45,6 +45,7 @@
4545
import java.io.InputStream;
4646
import java.util.Arrays;
4747
import java.util.List;
48+
import java.util.ArrayList;
4849

4950
import static processing.app.I18n._;
5051

@@ -57,6 +58,8 @@ public class LibrariesIndexer {
5758
private final File indexFile;
5859
private final File stagingFolder;
5960
private File sketchbookLibrariesFolder;
61+
62+
private static final List<String> badLibNotified = new ArrayList<String>();
6063

6164
public LibrariesIndexer(File preferencesFolder) {
6265
indexFile = new File(preferencesFolder, "library_index.json");
@@ -117,11 +120,18 @@ private void scanInstalledLibraries(File folder, boolean isSketchbook) {
117120

118121
for (File subfolder : list) {
119122
if (!BaseNoGui.isSanitaryName(subfolder.getName())) {
120-
String mess = I18n.format(_("The library \"{0}\" cannot be used.\n"
123+
124+
// Detect whether the current folder name has already had a notification.
125+
if(!badLibNotified.contains(subfolder.getName())) {
126+
127+
badLibNotified.add(subfolder.getName());
128+
129+
String mess = I18n.format(_("The library \"{0}\" cannot be used.\n"
121130
+ "Library names must contain only basic letters and numbers.\n"
122131
+ "(ASCII only and no spaces, and it cannot start with a number)"),
123132
subfolder.getName());
124-
BaseNoGui.showMessage(_("Ignoring bad library name"), mess);
133+
BaseNoGui.showMessage(_("Ignoring bad library name"), mess);
134+
}
125135
continue;
126136
}
127137

0 commit comments

Comments
 (0)