Skip to content

Commit

Permalink
Suppress missing active tab error
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Feb 2, 2024
1 parent 1022cb3 commit 89c64ca
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions webextensions/common/tst-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1245,13 +1245,20 @@ async function getTabFromWrongId({ id, activeWindow, sender }) {
id = id.id;
let query = String(id).toLowerCase();
let baseTab = Tab.getActiveTab(activeWindow.id);

// this sometimes happen when the active tab was detached from the window
if (!baseTab)
return null;

const nonActiveTabMatched = query.match(/^([^-]+)-of-(.+)$/i);
if (nonActiveTabMatched) {
query = nonActiveTabMatched[1];
id = nonActiveTabMatched[2];
if (/^\d+$/.test(id))
id = parseInt(id);
baseTab = Tab.get(id) || Tab.getByUniqueId(id);
if (!baseTab)
return null;
}
switch (query) {
case 'active':
Expand Down

0 comments on commit 89c64ca

Please sign in to comment.