diff --git a/src/completions.ts b/src/completions.ts
index 185dd825..c3aaadd9 100644
--- a/src/completions.ts
+++ b/src/completions.ts
@@ -669,10 +669,7 @@ export class BufferCompletionSource extends CompletionSourceFuse {
class BufferAllCompletionOption extends CompletionOptionHTML {
public fuseKeys = []
- constructor(
- public value: string,
- tab: browser.tabs.Tab,
- ) {
+ constructor(public value: string, tab: browser.tabs.Tab, winindex: number) {
super()
this.fuseKeys.push(String(tab.id), tab.title, tab.url)
@@ -681,7 +678,7 @@ class BufferAllCompletionOption extends CompletionOptionHTML {
this.html = html`
|
 |
- ${tab.id}: ${tab.title} |
+ ${winindex}.${tab.index + 1}: ${tab.title} |
${
tab.url
} |
@@ -693,11 +690,7 @@ export class BufferAllCompletionSource extends CompletionSourceFuse {
public options: BufferAllCompletionOption[]
constructor(private _parent) {
- super(
- ["bufferall "],
- "BufferAllCompletionSource",
- "All Buffers",
- )
+ super(["bufferall "], "BufferAllCompletionSource", "All Buffers")
this.updateOptions()
this._parent.appendChild(this.node)
@@ -716,21 +709,31 @@ export class BufferAllCompletionSource extends CompletionSourceFuse {
const options = []
tabs.sort((a, b) => {
- return a.index < b.index ? -1 : 1
+ if (a.windowId == b.windowId) return a.index - b.index
+ return a.windowId - b.windowId
})
+ // Window Ids don't make sense so we're using LASTID and IDCOUNT to compute a window index
+ // This relies on the fact that tabs are sorted by window ids
+ let lastId = 0
+ let index = 0
for (const tab of tabs) {
+ if (lastId != tab.windowId) {
+ lastId = tab.windowId
+ index += 1
+ }
options.push(
- new BufferAllCompletionOption(
- (tab.id).toString(),
- tab,
- ),
+ new BufferAllCompletionOption(tab.id.toString(), tab, index),
)
}
this.options = options
this.updateChain()
}
+
+ setStateFromScore(scoredOpts: ScoredOption[]) {
+ super.setStateFromScore(scoredOpts, true)
+ }
}
// {{{ UNUSED: MANAGING ASYNC CHANGES
diff --git a/src/config.ts b/src/config.ts
index ffaa34d4..14b0eb32 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -104,7 +104,7 @@ const DEFAULTS = o({
// "n": "findnext 1",
// "N": "findnext -1",
M: "gobble 1 quickmark",
- // "B": "fillcmdline bufferall",
+ B: "fillcmdline bufferall",
b: "fillcmdline buffer",
ZZ: "qall",
f: "hint",
diff --git a/src/excmds.ts b/src/excmds.ts
index 1dfadbeb..aec33b54 100644
--- a/src/excmds.ts
+++ b/src/excmds.ts
@@ -1983,6 +1983,9 @@ export async function buffer(index: number | "#") {
*/
//#background
export async function bufferall(id: number) {
+ if (id === null || id === undefined) {
+ id = (await activeTab()).id
+ }
await browser.windows.update((await browser.tabs.get(id)).windowId, { focused: true })
await browser.tabs.update(id, { active: true })
}