add:  if (gReplaceDialog.searchBackwards.checked && newRange) { gEditor.selection.removeAllRanges(); gEditor.selection.addRange(newRange); }  
context: function onReplace(){  if (!gEditor)    return false;  // Does the current selection match the find string?  var selection = gEditor.selection;  var selStr = selection.toString();  var specStr = gReplaceDialog.findInput.value;  if (!gReplaceDialog.caseSensitive.checked)  {    selStr = selStr.toLowerCase();    specStr = specStr.toLowerCase();  }  // Unfortunately, because of whitespace we can't just check  // whether (selStr == specStr), but have to loop ourselves.  // N chars of whitespace in specStr can match any M >= N in selStr.  var matches = true;  var specLen = specStr.length;  var selLen = selStr.length;  if (selLen < specLen)    matches = false;  else  {    var specArray = specStr.match(/\S+|\s+/g);    var selArray = selStr.match(/\S+|\s+/g);    if ( specArray.length != selArray.length)      matches = false;    else    {      for (var i=0; i<selArray.length; i++)      {        if (selArray[i] != specArray[i])        {          if ( selArray[i][0].search(/\s/) == -1 ||               specArray[i][0].search(/\s/) == -1)          {            // lowercase \s, not a space chunk -- match fails            matches = false;            break;          }          else if ( selArray[i].length < specArray[i].length )          {            // if it's a space chunk then we only care that sel be            // at least as long as spec            matches = false;            break;          }        }      }    }  }  // If the current selection doesn't match the pattern,  // then we want to find the next match, but not do the replace.  // That's what most other apps seem to do.  if (!matches)    return onFindNext();  // Transfer dialog contents to the find service.  saveFindData();  // nsPlaintextEditor::InsertText fails if the string is empty,  // so make that a special case:  var replStr = gReplaceDialog.replaceInput.value;  if (replStr == "")    gEditor.deleteSelection(0);  else    gEditor.insertText(replStr);  return true;}
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9421/74da9b4ffe38456fee34ee085a5a9e25988f3ebb/EdReplace.js/clean/editor/ui/dialogs/content/EdReplace.js