mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 01:51:40 -05:00
Merge pull request #3262 from jgkamat/jay/dedupe-taball
Migrate taball functionality into tab and alias them
This commit is contained in:
commit
071b6bd6b3
1 changed files with 16 additions and 15 deletions
|
@ -3296,32 +3296,33 @@ export async function yankimage(url: string): Promise<void> {
|
||||||
|
|
||||||
/** Change active tab.
|
/** Change active tab.
|
||||||
|
|
||||||
@param index
|
@param id
|
||||||
Starts at 1. 0 refers to last tab of the current window, -1 to penultimate tab, etc.
|
A bare number means the current window is used. Starts at 1. 0 refers to last tab of the current window, -1 to penultimate tab, etc.
|
||||||
|
|
||||||
|
A string following the following format: "[0-9]+.[0-9]+" means the first number being the index of the window that should be selected and the second one being the index of the tab within that window. [[taball]] has completions for this format.
|
||||||
|
|
||||||
"#" means the tab that was last accessed in this window
|
"#" means the tab that was last accessed in this window
|
||||||
|
|
||||||
This is different from [[taball]] because `index` is the position of the tab in the current window.
|
|
||||||
*/
|
*/
|
||||||
//#background
|
//#background
|
||||||
export async function tab(index: number | "#") {
|
export async function tab(id: string) {
|
||||||
return tabIndexSetActive(index)
|
if (Number.isInteger(Number(id)))
|
||||||
}
|
return tabIndexSetActive(Number(id));
|
||||||
|
if (id === "#")
|
||||||
|
return tabIndexSetActive(id);
|
||||||
|
|
||||||
/** Change active tab.
|
|
||||||
|
|
||||||
@param id
|
|
||||||
A string following the following format: "[0-9]+.[0-9]+", the first number being the index of the window that should be selected and the second one being the index of the tab within that window.
|
|
||||||
|
|
||||||
*/
|
|
||||||
//#background
|
|
||||||
export async function taball(id: string) {
|
|
||||||
const [winid, tabindex_number] = await parseWinTabIndex(id)
|
const [winid, tabindex_number] = await parseWinTabIndex(id)
|
||||||
const tabid = (await browser.tabs.query({ windowId: winid, index: tabindex_number }))[0].id
|
const tabid = (await browser.tabs.query({ windowId: winid, index: tabindex_number }))[0].id
|
||||||
await browser.windows.update(winid, { focused: true })
|
await browser.windows.update(winid, { focused: true })
|
||||||
return browser.tabs.update(tabid, { active: true })
|
return browser.tabs.update(tabid, { active: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Wrapper for [[tab]] with multi-window completions
|
||||||
|
*/
|
||||||
|
//#background
|
||||||
|
export async function taball(id: string) {
|
||||||
|
return tab(id);
|
||||||
|
}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
|
|
Loading…
Add table
Reference in a new issue