From a7ddcb1b5aec45dae7febbbf3e5067f964db14ba Mon Sep 17 00:00:00 2001 From: glacambre Date: Mon, 10 Sep 2018 07:05:47 +0200 Subject: [PATCH] Respect the tabs.move/tabs.create API According to MDN[1], when you create a tab that should be placed at the end of a window, you should use the number of tabs of the window as index. But if you use tabs.move(), you should use an index value of -1[2]. Probably fixes https://github.com/tridactyl/tridactyl/issues/990 . 1: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/create#Parameters 2: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/move#Parameters --- src/excmds.ts | 2 +- src/lib/webext.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/excmds.ts b/src/excmds.ts index b4a8051d..063aaa31 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -338,7 +338,7 @@ export async function nativeopen(url: string, ...firefoxArgs: string[]) { let index = (await activeTab()).index + 1 switch (pos) { case "last": - index = 99999 + index = -1 break case "related": // How do we simulate that? diff --git a/src/lib/webext.ts b/src/lib/webext.ts index 1e5e8fce..77d6658a 100644 --- a/src/lib/webext.ts +++ b/src/lib/webext.ts @@ -114,7 +114,7 @@ export async function openInNewTab( break case "last": // Infinity can't be serialised, apparently. - options.index = 99999 + options.index = (await browserBg.tabs.query({currentWindow: true})).length break case "related": if (await firefoxVersionAtLeast(57)) {