From 4adbe4b87a226b1bf7bd0d4c93c1046ed0259224 Mon Sep 17 00:00:00 2001 From: Manindra Moharana Date: Sun, 24 Feb 2013 17:57:08 +0530 Subject: [PATCH] Fixes #1643 --- app/src/processing/app/FindReplace.java | 26 +++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/app/src/processing/app/FindReplace.java b/app/src/processing/app/FindReplace.java index 9ee94c0c6..922bcc9ba 100644 --- a/app/src/processing/app/FindReplace.java +++ b/app/src/processing/app/FindReplace.java @@ -26,6 +26,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; /** @@ -317,7 +319,17 @@ public class FindReplace extends JFrame { break; } - text = sketch.getCode(tabIndex + 1).getProgram(); + try { + Document doc = sketch.getCode(tabIndex + 1).getDocument(); + if(doc != null) { + text = doc.getText(0, doc.getLength()); // this thing has the latest changes + } + else { + text = sketch.getCode(tabIndex + 1).getProgram(); // not this thing. + } + } catch (BadLocationException e) { + e.printStackTrace(); + } tabIndex++; if (ignoreCase) { text = text.toLowerCase(); @@ -358,7 +370,17 @@ public class FindReplace extends JFrame { } else if (tabIndex == 0) { break; } - text = sketch.getCode(tabIndex - 1).getProgram(); + try { + Document doc = sketch.getCode(tabIndex - 1).getDocument(); + if(doc != null) { + text = doc.getText(0, doc.getLength()); // this thing has the latest changes + } + else { + text = sketch.getCode(tabIndex - 1).getProgram(); // not this thing. + } + } catch (BadLocationException e) { + e.printStackTrace(); + } tabIndex--; if (ignoreCase) { text = text.toLowerCase();