Fix #404: add winmerge command

This commit is contained in:
Oliver Blanthorn 2020-06-27 13:49:07 +01:00
parent ff88686739
commit d36246a6a4
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3
2 changed files with 19 additions and 1 deletions

View file

@ -32,7 +32,11 @@ export class WindowCompletionSource extends Completions.CompletionSourceFuse {
public options: WindowCompletionOption[]
constructor(private _parent) {
super(["tabpush", "winclose"], "WindowCompletionSource", "Windows")
super(
["tabpush", "winclose", "winmerge"],
"WindowCompletionSource",
"Windows",
)
this.updateOptions()
this._parent.appendChild(this.node)

View file

@ -2091,6 +2091,20 @@ export async function tabpush(windowId: number) {
return activeTabId().then(tabId => browser.tabs.move(tabId, { index: -1, windowId }))
}
/**
* Moves all of the targetted window's tabs to the current window. Only works for windows of the same type
* (can't merge a non-private tab with a private window).
*/
//#background
export async function winmerge(windowId: number) {
const target_win = await browser.windows.get(windowId, { populate: true })
const active_win = await browser.windows.getCurrent()
return browser.tabs.move(
target_win.tabs.map(t => t.id),
{ index: -1, windowId: active_win.id },
)
}
/**
* Given a string of the format windowIndex.tabIndex, returns a tuple of
* numbers corresponding to the window index and tab index or the current