From 725461f04e62ee036c6b87fcaeaf8296d9831929 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Fri, 26 Oct 2012 18:36:33 +0100 Subject: [PATCH] Make searches case insensitive by default This is to match finding in files and is typically the default. Need to extend this logic to find in all documents and also filenames. Also add case insensitive switch to find/replace control. --- lib/ice-coder.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/ice-coder.js b/lib/ice-coder.js index ff7026a..e24d625 100644 --- a/lib/ice-coder.js +++ b/lib/ice-coder.js @@ -782,27 +782,27 @@ var ICEcoder = { var find, replace, results, cM, content, lineCount, numChars, charsToCursor, charCount, cursor, replaceQS, targetQS; // Determine our find & replace strings and the length of them - find = top.document.getElementById('find').value; - replace = top.document.getElementById('replace').value; + find = top.document.getElementById('find').value.toLowerCase(); + replace = top.document.getElementById('replace').value.toLowerCase(); results = top.document.getElementById('results'); // If we have something to find in currrent document if (find.length>0 && document.findAndReplace.target.value=="this document") { cM = ICEcoder.getcMInstance(); - content = cM.getValue(); + content = cM.getValue().toLowerCase(); // Find & replace the next instance, or all? if (document.findAndReplace.connector.value=="and") { - if (document.findAndReplace.replaceAction.value=="replace" && cM.getSelection()==find) { + if (document.findAndReplace.replaceAction.value=="replace" && cM.getSelection().toLowerCase()==find) { cM.replaceSelection(replace); } else if (document.findAndReplace.replaceAction.value=="replace all" && buttonClick) { - var rExp = new RegExp(find,"g"); + var rExp = new RegExp(find,"gi"); cM.setValue(cM.getValue().replace(rExp,replace)); } } // Get the content again, as it might of changed - content = cM.getValue(); + content = cM.getValue().toLowerCase(); if (!top.ICEcoder.findMode||find!=top.ICEcoder.lastsearch) { ICEcoder.results = []; @@ -858,10 +858,10 @@ var ICEcoder = { charCount++; } - cursor = cM.getSearchCursor(find,cM.getCursor()); + cursor = cM.getSearchCursor(find,cM.getCursor(),true); cursor.findNext(); if (!cursor.from()) { - cursor = cM.getSearchCursor(find,{line:0,ch:0}); + cursor = cM.getSearchCursor(find,{line:0,ch:0},true); cursor.findNext(); } // Finally, highlight our selection