mirror of
https://github.com/tridactyl/tridactyl.git
synced 2026-09-10 07:16:33 -04:00
Fix #5493: add :splitnext
This commit is contained in:
parent
9c8c15ff77
commit
fb7d2feeef
|
|
@ -217,6 +217,27 @@ test("`changelistjump` skips closed tabs", async () => {
|
|||
])
|
||||
})
|
||||
|
||||
test.each([
|
||||
[7, [[2, { active: true }]]],
|
||||
[-1, []],
|
||||
[undefined, []],
|
||||
])(
|
||||
"`splitnext` handles split view ID %s",
|
||||
async (splitViewId, expectedCalls) => {
|
||||
const query = jest.mocked(browser.tabs.query)
|
||||
const update = jest.mocked(browser.tabs.update)
|
||||
update.mockClear()
|
||||
query.mockResolvedValueOnce([
|
||||
{ id: 1, active: true, splitViewId },
|
||||
{ id: 2, active: false, splitViewId },
|
||||
] as browser.tabs.Tab[])
|
||||
|
||||
await backgroundExcmds.splitnext()
|
||||
expect(query).toHaveBeenLastCalledWith({ currentWindow: true })
|
||||
expect(update.mock.calls).toEqual(expectedCalls)
|
||||
},
|
||||
)
|
||||
|
||||
test("`nativeopen` targets the running macOS Firefox application", async () => {
|
||||
jest.mocked(browser.runtime.getPlatformInfo).mockResolvedValue({
|
||||
arch: "x86-64",
|
||||
|
|
|
|||
|
|
@ -2739,6 +2739,16 @@ async function tabIndexSetActive(index: number | string) {
|
|||
return tabSetActive(await idFromIndex(index))
|
||||
}
|
||||
|
||||
/** Switch focus to the other side of the current split view, if it exists */
|
||||
//#background
|
||||
export async function splitnext() {
|
||||
const tabs = await browser.tabs.query({ currentWindow: true })
|
||||
const splitViewId = tabs.find(tab => tab.active)?.splitViewId
|
||||
if (splitViewId === undefined || splitViewId < 0) return
|
||||
const next = tabs.find(tab => !tab.active && tab.splitViewId === splitViewId)
|
||||
if (next) return tabSetActive(next.id)
|
||||
}
|
||||
|
||||
/** Switch to the first tab in Firefox's tab order. */
|
||||
//#background
|
||||
export async function tabfirst() {
|
||||
|
|
|
|||
|
|
@ -325,6 +325,7 @@ export class default_config {
|
|||
K: "tabnext",
|
||||
gt: "tabnext_gt",
|
||||
gT: "tabprev",
|
||||
gs: "splitnext", // c-w w is reserved for closing windows
|
||||
// "<c-n>": "tabnext_gt", // c-n is reserved for new window
|
||||
// "<c-p>": "tabprev",
|
||||
"g^": "tabfirst",
|
||||
|
|
|
|||
6
src/tridactyl.d.ts
vendored
6
src/tridactyl.d.ts
vendored
|
|
@ -20,6 +20,12 @@ interface HTMLElement {
|
|||
openOrClosedShadowRoot: ShadowRoot | null
|
||||
}
|
||||
|
||||
declare namespace browser.tabs {
|
||||
interface Tab {
|
||||
splitViewId?: number
|
||||
}
|
||||
}
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
|
||||
// these functions really can be anything, ditto for the objects
|
||||
declare function exportFunction(
|
||||
|
|
|
|||
Loading…
Reference in a new issue