rem: if (treeSelection.count == 0) { 
add: if (!treeSelection) {    return; } else if (treeSelection.count == 0) { 
context: function HandleDeleteOrMoveMessageCompleted(folder){  var treeView = gSearchView.QueryInterface(Components.interfaces.nsITreeView);  var treeSelection = treeView.selection;  var viewSize = treeView.rowCount;  if (gNextMessageViewIndexAfterDelete == -2) {    // a move or delete can cause our selection can change underneath us.    // this can happen when the user    // deletes message from the stand alone msg window    // or the three pane    if (treeSelection.count == 0) {      // this can happen if you double clicked a message      // in the thread pane, and deleted it from the stand alone msg window      // see bug #185147      treeSelection.clearSelection();      UpdateMailSearch("delete from another view, 0 rows now selected");    }    else if (treeSelection.count == 1) {      // this can happen if you had two messages selected      // in the search results pane, and you deleted one of them from another view      // (like the view in the stand alone msg window or the three pane)      // since one item is selected, we should load it.      var startIndex = {};      var endIndex = {};      treeSelection.getRangeAt(0, startIndex, endIndex);              // select the selected item, so we'll load it      treeSelection.select(startIndex.value);       treeView.selectionChanged();      EnsureRowInThreadTreeIsVisible(startIndex.value);       UpdateMailSearch("delete from another view, 1 row now selected");    }    else {      // this can happen if you have more than 2 messages selected      // in the search results pane, and you deleted one of them from another view      // (like the view in the stand alone msg window or the three pane)      // since multiple messages are still selected, do nothing.    }  }  else {    if (gNextMessageViewIndexAfterDelete != nsMsgViewIndex_None && gNextMessageViewIndexAfterDelete >= viewSize)     {      if (viewSize > 0)        gNextMessageViewIndexAfterDelete = viewSize - 1;      else      {                   gNextMessageViewIndexAfterDelete = nsMsgViewIndex_None;        // there is nothing to select since viewSize is 0        treeSelection.clearSelection();        UpdateMailSearch("delete from current view, 0 rows left");      }    }    // if we are about to set the selection with a new element then DON'T clear    // the selection then add the next message to select. This just generates    // an extra round of command updating notifications that we are trying to    // optimize away.    if (gNextMessageViewIndexAfterDelete != nsMsgViewIndex_None)     {      treeSelection.select(gNextMessageViewIndexAfterDelete);      // since gNextMessageViewIndexAfterDelete probably has the same value      // as the last index we had selected, the tree isn't generating a new      // selectionChanged notification for the tree view. So we aren't loading the       // next message. to fix this, force the selection changed update.      if (treeView)        treeView.selectionChanged();      EnsureRowInThreadTreeIsVisible(gNextMessageViewIndexAfterDelete);       // XXX TODO      // I think there is a bug in the suppression code above.      // what if I have two rows selected, and I hit delete,       // and so we load the next row.      // what if I have commands that only enable where       // exactly one row is selected?      UpdateMailSearch("delete from current view, at least one row selected");    }  }  // default value after delete/move/copy is over  gNextMessageViewIndexAfterDelete = -2;  // something might have been deleted, so update the status text  SetAdvancedSearchStatusText(viewSize);}
meta: 10234	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/10234/c4244eaf64ee50d09079700c3c0413c0377eaccf/SearchDialog.js/buggy/mailnews/base/search/resources/content/SearchDialog.js