Skip to content

Commit 0d39bdb

Browse files
committed
Fix a problem the default template is duplicated #41
1 parent 7775449 commit 0d39bdb

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.junichi11</groupId>
55
<artifactId>netbeans-github-issues</artifactId>
6-
<version>0.1.3</version>
6+
<version>0.1.4-SNAPSHOT</version>
77
<packaging>nbm</packaging>
88
<build>
99
<plugins>

src/main/java/com/junichi11/netbeans/modules/github/issues/GitHubIssuesConfig.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
import java.text.ParseException;
5050
import java.text.SimpleDateFormat;
5151
import java.util.ArrayList;
52-
import java.util.Arrays;
5352
import java.util.Date;
5453
import java.util.prefs.BackingStoreException;
5554
import java.util.prefs.Preferences;
@@ -248,9 +247,16 @@ public String[] getTemplateNames() {
248247
names.add(DEFAULT_TEMPLATE_NAME);
249248
Preferences preferences = getPreferences().node(TEMPLATE);
250249
try {
250+
// contains the default template if it was edited
251251
String[] childrenNames = preferences.keys();
252-
names.addAll(Arrays.asList(childrenNames));
253-
return names.toArray(new String[childrenNames.length + 1]);
252+
int count = 1; // default template
253+
for (String childName : childrenNames) {
254+
if (!childName.equals(DEFAULT_TEMPLATE_NAME)) {
255+
names.add(childName);
256+
count++;
257+
}
258+
}
259+
return names.toArray(new String[count]);
254260
} catch (BackingStoreException ex) {
255261
Exceptions.printStackTrace(ex);
256262
}

0 commit comments

Comments
 (0)