mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 17:41:40 -05:00
Rewrite nextTab, fix multiple windows
This commit is contained in:
parent
5951a29ce7
commit
db06783c8c
1 changed files with 10 additions and 9 deletions
|
@ -55,15 +55,16 @@ displayTab = (tab_id) ->
|
||||||
browser.browserAction.onClicked.addListener(handleBrowserAction)
|
browser.browserAction.onClicked.addListener(handleBrowserAction)
|
||||||
|
|
||||||
nextTab = () ->
|
nextTab = () ->
|
||||||
browser.tabs.query({active:true}).then((tabs) ->
|
browser.windows.getCurrent().then(
|
||||||
id = tabs[0].id
|
(window) ->
|
||||||
index = tabs[0].index
|
browser.tabs.query({windowId:window.id}).then(
|
||||||
desIndex = index + 1
|
(tabs) ->
|
||||||
browser.tabs.query({}).then((tabs) ->
|
active = (tab for tab in tabs when tab.active)[0]
|
||||||
desId = tab for tab in tabs when tab.index == desIndex
|
nextIndex = (active.index + 1) % tabs.length
|
||||||
setTab(desId.id)
|
desiredTab = (tab for tab in tabs when tab.index == nextIndex)[0]
|
||||||
)
|
setTab(desiredTab.id)
|
||||||
)
|
).catch(console.error)
|
||||||
|
).catch(console.error)
|
||||||
|
|
||||||
setTab = (id) ->
|
setTab = (id) ->
|
||||||
browser.tabs.update(id,{active:true})
|
browser.tabs.update(id,{active:true})
|
||||||
|
|
Loading…
Add table
Reference in a new issue