From d89bb1e7ae853c4ae24aa12d8cc6922b47b01b77 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Fri, 20 Oct 2017 17:19:29 -0400 Subject: [PATCH] avoid NPEs when no selection --- app/src/processing/app/ui/Editor.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/processing/app/ui/Editor.java b/app/src/processing/app/ui/Editor.java index 2c5ed8613..be85d5b5b 100644 --- a/app/src/processing/app/ui/Editor.java +++ b/app/src/processing/app/ui/Editor.java @@ -2222,7 +2222,7 @@ public abstract class Editor extends JFrame implements RunnerListener { int last = Math.min(location + tabSize, textarea.getDocumentLength()); textarea.select(location, last); // Don't eat code if it's not indented - if (textarea.getSelectedText().equals(tabString)) { + if (tabString.equals(textarea.getSelectedText())) { textarea.setSelectedText(""); } } @@ -2321,11 +2321,11 @@ public abstract class Editor extends JFrame implements RunnerListener { if (ref != null) { showReference(ref + ".html"); } else { - String text = textarea.getSelectedText().trim(); - if (text.length() == 0) { + String text = textarea.getSelectedText(); + if (text == null) { statusNotice(Language.text("editor.status.find_reference.select_word_first")); } else { - statusNotice(Language.interpolate("editor.status.find_reference.not_available", text)); + statusNotice(Language.interpolate("editor.status.find_reference.not_available", text.trim())); } } }