diff --git a/content/treestyletab/windowHelper.js b/content/treestyletab/windowHelper.js index 1b35e03d..0fb703f8 100644 --- a/content/treestyletab/windowHelper.js +++ b/content/treestyletab/windowHelper.js @@ -455,22 +455,16 @@ var TreeStyleTabWindowHelper = { return eval(aName+' = '+aSource.replace( 'if (nextTab)', '(function() {\n' + - ' if (this.treeStyleTab.hasChildTabs(this.mCurrentTab)) {\n' + - ' let descendant = this.treeStyleTab.getDescendantTabs(this.mCurrentTab);\n' + - ' if (descendant.length)\n' + - ' nextTab = this.treeStyleTab.getNextTab(descendant[descendant.length-1]);\n' + + ' let descendants = this.treeStyleTab.getDescendantTabs(this.mCurrentTab);\n' + + ' if (descendants.indexOf(nextTab) > -1) {\n' + + ' let lastDescendant = this.treeStyleTab.getLastDescendantTab(this.mCurrentTab);\n' + + ' nextTab = this.treeStyleTab.getNextVisibleTab(lastDescendant || this.mCurrentTab);\n' + + ' }\n' + + ' if (this.treeStyleTab.hasChildTabs(nextTab) && this.treeStyleTab.isSubtreeCollapsed(nextTab)) {\n' + + ' nextTab = this.treeStyleTab.getLastDescendantTab(nextTab);\n' + ' }\n' + '}).call(this);' + '$&' - ).replace( - /(this.moveTabTo\([^;]+\);)/, - '(function() {\n' + - ' let descendant = this.treeStyleTab.getDescendantTabs(nextTab);\n' + - ' if (descendant.length) {\n' + - ' nextTab = descendant[descendant.length-1];\n' + - ' }\n' + - ' $1\n' + - '}).call(this);' ).replace( 'this.moveTabToStart();', '(function() {\n' + @@ -490,6 +484,12 @@ var TreeStyleTabWindowHelper = { TreeStyleTabUtils.doPatching(b.moveTabBackward, 'b.moveTabBackward', function(aName, aSource) { return eval(aName+' = '+aSource.replace( + 'if (previousTab)', + '(function() {\n' + + ' previousTab = this.treeStyleTab.getPreviousVisibleTab(this.mCurrentTab);\n' + + '}).call(this);' + + '$&' + ).replace( 'this.moveTabToEnd();', '(function() {\n' + ' this.treeStyleTab.internallyTabMovingCount++;\n' + diff --git a/modules/browser.js b/modules/browser.js index aa2413c1..ae9a52cc 100644 --- a/modules/browser.js +++ b/modules/browser.js @@ -3678,9 +3678,10 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, { aOldPosition = aTab._tPos; var pos = this.getChildIndex(aTab, parent); - var oldPos = this.getChildIndex(this.getAllTabs(this.mTabBrowser)[aOldPosition], parent); + var oldPositionTab = this.getAllTabs(this.mTabBrowser)[aOldPosition]; + var oldPos = this.getChildIndex(oldPositionTab, parent); var delta; - if (pos == oldPos) { // no move? + if (oldPositionTab == aTab && pos == oldPos) { // no move? mydump(' => no move\n'); return; } @@ -3693,8 +3694,8 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, { mydump((new Error()).stack.replace(/^/gm, ' ')+'\n'); - var prevTab = this.getPreviousTab(aTab); - var nextTab = this.getNextTab(aTab); + var prevTab = this.getPreviousVisibleTab(aTab); + var nextTab = this.getNextVisibleTab(aTab); var tabs = this.getDescendantTabs(aTab); if (tabs.length) {