diff --git a/src/completions/BufferAll.ts b/src/completions/BufferAll.ts
index c278c909..78c3bd21 100644
--- a/src/completions/BufferAll.ts
+++ b/src/completions/BufferAll.ts
@@ -4,10 +4,10 @@ import * as Completions from "../completions"
class BufferAllCompletionOption extends Completions.CompletionOptionHTML
implements Completions.CompletionOptionFuse {
public fuseKeys = []
-
constructor(public value: string, tab: browser.tabs.Tab, winindex: number) {
super()
- this.fuseKeys.push(String(tab.id), tab.title, tab.url)
+ this.value = `${winindex}.${tab.index + 1}`
+ this.fuseKeys.push(this.value, tab.title, tab.url)
// Create HTMLElement
const favIconUrl = tab.favIconUrl
@@ -16,7 +16,7 @@ class BufferAllCompletionOption extends Completions.CompletionOptionHTML
this.html = html`
|
 |
- ${winindex}.${tab.index + 1}: ${tab.title} |
+ ${this.value}: ${tab.title} |
${
tab.url
} |
@@ -51,17 +51,17 @@ export class BufferAllCompletionSource extends Completions.CompletionSourceFuse
return a.windowId - b.windowId
})
- // Window Ids don't make sense so we're using LASTID and IDCOUNT to compute a window index
+ // Window Ids don't make sense so we're using LASTID and WININDEX to compute a window index
// This relies on the fact that tabs are sorted by window ids
let lastId = 0
- let index = 0
+ let winindex = 0
for (const tab of tabs) {
if (lastId != tab.windowId) {
lastId = tab.windowId
- index += 1
+ winindex += 1
}
options.push(
- new BufferAllCompletionOption(tab.id.toString(), tab, index),
+ new BufferAllCompletionOption(tab.id.toString(), tab, winindex),
)
}
diff --git a/src/excmds.ts b/src/excmds.ts
index aec33b54..b4ab4962 100644
--- a/src/excmds.ts
+++ b/src/excmds.ts
@@ -1977,17 +1977,21 @@ export async function buffer(index: number | "#") {
/** Change active tab.
@param id
- The id of the tab that should be selected.
+ 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.
- This is different from [[buffer]] because `id` is the internal firefox id of the tab, this means that you can focus tabs that aren't in the current window.
*/
//#background
-export async function bufferall(id: number) {
- if (id === null || id === undefined) {
- id = (await activeTab()).id
+export async function bufferall(id: string) {
+ let windows = (await browser.windows.getAll()).map(w => w.id).sort()
+ if (id === null || id === undefined || !id.match(/\d+\.\d+/)) {
+ const tab = await activeTab()
+ let prevId = id
+ id = windows.indexOf(tab.windowId) + "." + (tab.index + 1)
+ logger.info(`bufferall: Bad tab id: ${prevId}, defaulting to ${id}`)
}
- await browser.windows.update((await browser.tabs.get(id)).windowId, { focused: true })
- await browser.tabs.update(id, { active: true })
+ let [winindex, tabindex] = id.split(".")
+ await browser.windows.update(windows[parseInt(winindex) - 1], { focused: true })
+ return browser.tabs.update(await idFromIndex(tabindex), { active: true })
}
// }}}