Skip to content

Commit 57a3ab8

Browse files
committed
Merge branch 'imagej-forum-3176'
This fixes a problem with backwards compatibility in ImageJ, where scripts ending in underscore previously retained a trailing space, but no longer did so in recent versions. See: http://forum.imagej.net/t/trouble-with-commands-being-recognized-in-macro/3176/15
2 parents 1215dd8 + 4202cc9 commit 57a3ab8

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/main/java/org/scijava/MenuPath.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,20 @@ public MenuPath(final String path) {
7474
* the specified separator.
7575
*/
7676
public MenuPath(final String path, final String separator) {
77+
this(path, separator, true);
78+
}
79+
80+
/**
81+
* Creates a menu path with entries parsed from the given string, splitting on
82+
* the specified separator, and trimming whitespace if indicated.
83+
*/
84+
public MenuPath(final String path, final String separator,
85+
final boolean trim)
86+
{
7787
if (path != null && !path.isEmpty()) {
7888
final String[] tokens = path.split(separator);
7989
for (final String token : tokens) {
80-
add(new MenuEntry(token.trim()));
90+
add(new MenuEntry(trim ? token.trim() : token));
8191
}
8292
}
8393
}

src/main/java/org/scijava/script/ScriptFinder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ private int createInfos(final List<ScriptInfo> scripts, final Set<URL> urls,
172172
final String friendlyPath = basePath.replace('_', ' ');
173173

174174
final MenuPath menuPath = new MenuPath(menuPrefix);
175-
menuPath.addAll(new MenuPath(friendlyPath, "/"));
175+
menuPath.addAll(new MenuPath(friendlyPath, "/", false));
176176

177177
// E.g.:
178178
// path = "File/Import/Movie_File....groovy"

0 commit comments

Comments
 (0)