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.
This commit is contained in:
Matt Pass
2012-10-26 18:36:33 +01:00
parent a3edd7bdf9
commit 725461f04e

View File

@@ -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