Fix v5 separate new tab position for tabs opened with new tab button #2008
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a dedicated setting for new tab position when Sidebery New Tab (+) button is clicked as requested in issue #1096
How it works
New Tab button calls function
createTabInPanel
. AFAIK this function is not called when native tab creation (for instance Ctrl+T) is used.createTabInPanel
callsgetIndexForNewTab
andgetParentForNewTab
(also latergetPanelForNewTab
might be called). For these functions I added the flagfromNewTabButton
in their object argument, so they have a way to determine how the tab was created (natively or from the New Tab button).By checking the flag they can choose the correct setting (
moveNewTab
ormoveNewTabButton
) from which the logic of tab placement is based.Remarks
dict.setup-page.ts
for keysettings.move_new_tab_button
since I used Google Translate.moveNewTabButton
reuses the possible values for settingmoveNewTab
(new tab position (general rule), that is['start', 'end', 'before', 'after', 'first_child', 'last_child', 'none']
. If dedicated options are needed, please ask.In order to DRY I used functions that I namedlast commit 5d3fdf3 avoids this.getIndexForNewTabOtherCases
,getParentForNewTabOtherCases
andgetPanelForNewTabOtherCases
because the logic is the same for settingsmoveNewTab
andmoveNewTabButton
. Let me know if I should name them otherwise but I could not think of something else.fromNewTabButton
is passed to the 3 functionsgetIndexForNewTab
,getParentForNewTab
andgetPanelForNewTab
in the same way, that is in a an object.Last but not least I did not test all the configurations for the different settings of new tab position since I did not understand them all.I tested all of the 7 options and when needed with/without active tab being pinned, for bothmoveNewTab
andmoveNewTabButton
.