From db286777def0593e671854ec318a75624466d267 Mon Sep 17 00:00:00 2001 From: SHIMODA Hiroshi Date: Mon, 5 Dec 2011 20:19:32 +0900 Subject: [PATCH] tree structure should be restored even if there are any extra tab --- modules/browser.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/modules/browser.js b/modules/browser.js index e0c24118..00f5442e 100644 --- a/modules/browser.js +++ b/modules/browser.js @@ -2345,7 +2345,8 @@ TreeStyleTabBrowser.prototype = { !treeStructure.state || !treeStructure.state.length || !treeStructure.tree || - !treeStructure.tree.length + !treeStructure.tree.length || + treeStructure.state.length != treeStructure.tree.length ) return; @@ -2353,13 +2354,21 @@ TreeStyleTabBrowser.prototype = { var actualTabs = tabs.map(function(aTab) { return this.getTabValue(aTab, this.kID); - }, this).join('\n'); - var expectedTabs = treeStructure.state.map(function(aState) { + }, this).join('\n')+'\n'; + var restoringTabs = treeStructure.state.map(function(aState) { return aState.id; - }).join('\n'); - if (actualTabs != expectedTabs) + }).join('\n')+'\n'; + if (actualTabs.indexOf(restoringTabs) < 0) return; + var preTabs = actualTabs + .split(restoringTabs)[0] + .replace(/\n$/, '') + .split('\n') + .filter(function(aId) { return aId; }) + .length; + tabs = tabs.slice(preTabs, preTabs + treeStructure.tree.length-1); + var relations = tabs.map(function(aTab) { return { id : this.getTabValue(aTab, this.kID), @@ -2369,7 +2378,7 @@ TreeStyleTabBrowser.prototype = { insertAfter : this.getTabValue(aTab, this.kINSERT_AFTER) }; }, this); - this.applyTreeStructureToTabBrowser(this.mTabBrowser, treeStructure.tree); + this.applyTreeStructureToTabs(tabs, treeStructure.tree); this.updateAllTabsIndent(true);