mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 17:41:40 -05:00
Make tabmove circular
Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
This commit is contained in:
parent
86c135996d
commit
fcfb9afda6
1 changed files with 12 additions and 2 deletions
|
@ -1792,9 +1792,19 @@ export async function undo() {
|
|||
//#background
|
||||
export async function tabmove(index = "0") {
|
||||
const aTab = await activeTab()
|
||||
const maxindex = (await browser.tabs.query({ currentWindow: true })).length - 1
|
||||
let newindex: number
|
||||
if (index.startsWith("+") || index.startsWith("-")) {
|
||||
newindex = Math.max(0, Number(index) + aTab.index)
|
||||
|
||||
if (index.startsWith("+")) {
|
||||
newindex = Number(index) + aTab.index
|
||||
if (newindex > maxindex) {
|
||||
newindex -= (maxindex + 1)
|
||||
}
|
||||
} else if (index.startsWith("-")) {
|
||||
newindex = Number(index) + aTab.index
|
||||
if (newindex < 0) {
|
||||
newindex += (maxindex + 1)
|
||||
}
|
||||
} else newindex = Number(index) - 1
|
||||
browser.tabs.move(aTab.id, { index: newindex })
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue