Skip to content

Commit ab2d83f

Browse files
committed
Index reference page is shown when no text selected if clicking 'Find in
reference' command.
1 parent 8a1cf33 commit ab2d83f

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

Diff for: app/src/processing/app/Editor.java

+18-20
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import processing.app.tools.*;
2828
import processing.core.*;
2929
import static processing.app.I18n._;
30+
import static processing.app.ObjectUtil.defaultIfEmpty;
3031

3132
import java.awt.*;
3233
import java.awt.datatransfer.*;
@@ -1073,9 +1074,10 @@ public void actionPerformed(ActionEvent e) {
10731074
item = newJMenuItemShift(_("Find in Reference"), 'F');
10741075
item.addActionListener(new ActionListener() {
10751076
public void actionPerformed(ActionEvent e) {
1076-
if (textarea.isSelectionActive()) {
1077-
handleFindReference();
1078-
}
1077+
// if (textarea.isSelectionActive()) {
1078+
// handleFindReference();
1079+
// }
1080+
handleFindReference();
10791081
}
10801082
});
10811083
menu.add(item);
@@ -1809,24 +1811,20 @@ protected void handleIndentOutdent(boolean indent) {
18091811
}
18101812

18111813

1812-
protected void handleFindReference() {
1813-
String text = textarea.getSelectedText().trim();
1814-
1815-
if (text.length() == 0) {
1816-
statusNotice(_("First select a word to find in the reference."));
1814+
protected void handleFindReference() {
1815+
String text = defaultIfEmpty(textarea.getSelectedText(), "").trim();
18171816

1818-
} else {
1819-
String referenceFile = PdeKeywords.getReference(text);
1820-
//System.out.println("reference file is " + referenceFile);
1821-
if (referenceFile == null) {
1822-
statusNotice(
1823-
I18n.format(_("No reference available for \"{0}\""), text)
1824-
);
1825-
} else {
1826-
Base.showReference(I18n.format(_("{0}.html"), referenceFile));
1827-
}
1828-
}
1829-
}
1817+
if (text.length() == 0) {
1818+
Base.showReference();
1819+
} else {
1820+
String referenceFile = PdeKeywords.getReference(text);
1821+
if (referenceFile == null) {
1822+
statusNotice(I18n.format(_("No reference available for \"{0}\""), text));
1823+
} else {
1824+
Base.showReference(I18n.format(_("{0}.html"), referenceFile));
1825+
}
1826+
}
1827+
}
18301828

18311829

18321830
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

0 commit comments

Comments
 (0)