rem: var originalFolderResource = RDF.GetResource(originalFolderURI); var folder = originalFolderResource.QueryInterface(Components.interfaces.nsIFolder); if (!folder) return null; 
add:    for (folder = gDBView.msgFolder; !folder.isServer; ) { 
context: function FindNextFolder(originalFolderURI){    if (!originalFolderURI) return null;    var originalFolderResource = RDF.GetResource(originalFolderURI);    var folder = originalFolderResource.QueryInterface(Components.interfaces.nsIFolder);    if (!folder) return null;    var originalMsgFolder = folder.QueryInterface(Components.interfaces.nsIMsgFolder);    // don't land on folders or subfolder of folders    // that we don't care about    if(!IgnoreFolderForNextNavigation(originalMsgFolder)) {      if (originalMsgFolder.getNumUnread(false /* don't descend */) > 0) {        return originalMsgFolder.URI;      }    }    // first check the children    var msgFolders = GetSubFoldersInFolderPaneOrder(folder);    var i;    for (i=0;i<msgFolders.length;i++) {      var currentSubFolder = msgFolders[i];      // don't land on folders we don't care about      if(!IgnoreFolderForNextNavigation(currentSubFolder)) {        if (currentSubFolder.getNumUnread(false /* don't descend */) > 0) {           // if the child has unread, use it.           return currentSubFolder.URI;        }        else if (currentSubFolder.getNumUnread(true /* descend */) > 0) {           // if the child doesn't have any unread, but it's children do, recurse           return FindNextFolder(currentSubFolder.URI);        }      }    }      // didn't find folder in children    // go up to the parent, and start at the folder after the current one    // unless we are at a server, in which case bail out.    if (originalMsgFolder.isServer) {      return null;    }    msgFolders = GetSubFoldersInFolderPaneOrder(folder.parent);    for (i=0;i<msgFolders.length;i++) {      if (msgFolders[i].URI == folder.URI)        break;    }        // the current folder is at index i    // start at the next folder after that, if there is one    if (i+1 < msgFolders.length) {      return FindNextFolder(msgFolders[i+1].URI);    }     try {      // none at this level after the current folder.  go up.      if (folder.parent && folder.parent.URI) {         var parentMsgFolder = folder.parent.QueryInterface(Components.interfaces.nsIMsgFolder);        if (parentMsgFolder.isServer) {          // we've already search the parent's children below us.          // don't search the server again, return null and let          // the caller search the next server          return null;        }        else {          return FindNextFolder(folder.parent.URI);        }      }    }    catch (ex) {      dump("XXX ex " + ex + "\n");    }    return null;}
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9421/a5bb53fbf340a039327f6d674880b7c1a74c3991/msgViewNavigation.js/buggy/mailnews/base/resources/content/msgViewNavigation.js