rem: var treeView = gDBView.QueryInterface(Components.interfaces.nsITreeView); var treeSelection = treeView.selection; if (gNextMessageViewIndexAfterDelete != nsMsgViewIndex_None) 
add: viewSize = treeView.rowCount; if (gNextMessageViewIndexAfterDelete >= viewSize) 
context: function HandleDeleteOrMoveMsgCompleted(folder){  // you might not have a db view.  this can happen if  // biff fires when the 3 pane is set to account central.  if (!gDBView)    return;  gDBView.onDeleteCompleted(true);  if (gNextMessageViewIndexAfterDelete != -2)   {    if (IsCurrentLoadedFolder(folder))     {      var treeView = gDBView.QueryInterface(Components.interfaces.nsITreeView);      var treeSelection = treeView.selection;      if (gNextMessageViewIndexAfterDelete != nsMsgViewIndex_None)       {        viewSize = treeView.rowCount;        if (gNextMessageViewIndexAfterDelete >= viewSize)         {          if (viewSize > 0)            gNextMessageViewIndexAfterDelete = viewSize - 1;          else          {                       gNextMessageViewIndexAfterDelete = nsMsgViewIndex_None;            //there is nothing to select viewSize is 0            treeSelection.clearSelection();            setTitleFromFolder(folder,null);            ClearMessagePane();          }        }      }      // 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)       {        // when deleting a message we don't update the commands when the selection goes to 0        // (we have a hack in nsMsgDBView which prevents that update) so there is no need to        // update commands when we select the next message after the delete; the commands already        // have the right update state...        gDBView.suppressCommandUpdating = true;        // This check makes sure that the tree does not perform a        // selection on a non selected row (row < 0), else assertions will        // be thrown.        if (gNextMessageViewIndexAfterDelete >= 0)          treeSelection.select(gNextMessageViewIndexAfterDelete);                // if gNextMessageViewIndexAfterDelete has the same value         // as the last index we had selected, the tree won't generate a        // selectionChanged notification for the tree view. So force a manual        // selection changed call. (don't worry it's cheap if we end up calling it twice).        if (treeView)          treeView.selectionChanged();        EnsureRowInThreadTreeIsVisible(gNextMessageViewIndexAfterDelete);         gDBView.suppressCommandUpdating = false;        // hook for extra toolbar items        // XXX 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?        NotifyObservers(window, "mail:updateToolbarItems", null);      }    }      gNextMessageViewIndexAfterDelete = -2;       //default value after delete/move/copy is over  }}
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9421/b039b7c3b8b4a787e7556b04d3527eb2a568826a/msgMail3PaneWindow.js/clean/mailnews/base/resources/content/msgMail3PaneWindow.js