mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 17:41:40 -05:00
Improve :bufferall, bind it to 'B'
This commit is contained in:
parent
575693a65e
commit
e27f93c913
3 changed files with 22 additions and 16 deletions
|
@ -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`<tr class="BufferAllCompletionOption option">
|
||||
<td class="prefix"></td>
|
||||
<td><img src=${favIconUrl} /></td>
|
||||
<td>${tab.id}: ${tab.title}</td>
|
||||
<td>${winindex}.${tab.index + 1}: ${tab.title}</td>
|
||||
<td><a class="url" target="_blank" href=${tab.url}>${
|
||||
tab.url
|
||||
}</a></td>
|
||||
|
@ -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
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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 })
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue