Fixup tree structure after tab move correctly.
Keyboard shortcuts Ctrl-Shift-PageUp/PageDown sometimes broke the tree. This commit fixes following cases: case 1: * [-] A * A-1 <= Ctrl-Shift-PageDown at here * [+] B then they should be: * A * [+] B * A-1 but actually: * [-] A * [+] B * A-1 <= still a child of A! case 2: * A * [-] B * [+] B-1 <= Ctrl-Shift-PageUp at here then they should be: * A * [+] B-1 * B but actually: * A * [+] B-1 <= still a child of B! * [-] B
This commit is contained in:
parent
1623bc43a9
commit
28ba3b54ad
@ -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' +
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user