From c368979295648428b0f28e118b3603aa29e7cd7d Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Wed, 2 Mar 2016 22:28:49 -0500
Subject: [PATCH] ignore case for search in the Pd Console window

---
 pd/nw/index.js | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/pd/nw/index.js b/pd/nw/index.js
index d71bb4b6b..ef0ff523a 100644
--- a/pd/nw/index.js
+++ b/pd/nw/index.js
@@ -98,12 +98,18 @@ function console_unwrap_tag(console_elem, tag_name) {
     }
 }
 
+// We need to use a regular expression to search without regard to case
+function escapeRegExp(string){
+  // $& means the whole matched string
+  return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
+}
 function console_find_text(evt, callback) {
     var console_text = document.getElementById("p1"),
         wrap_tag = "mark",
         wrapper_count,
         elem = evt.target;
     window.setTimeout(function () {
+        var find_text = new RegExp(escapeRegExp(elem.value), "gi");
         console_unwrap_tag(console_text, wrap_tag);
         // Check after the event if the value is empty
         if (elem.value === undefined || elem.value === "") {
@@ -112,7 +118,7 @@ function console_find_text(evt, callback) {
         } else {
             window.findAndReplaceDOMText(console_text, {
                 //preset: "prose",
-                find: elem.value.toLowerCase(),
+                find: find_text,
                 wrap: wrap_tag
             });
             // The searchAndReplace API is so bad you can't even know how
-- 
GitLab