feat: add reopen closed tab command

This commit is contained in:
Nybkox
2024-11-22 02:18:01 +01:00
parent 477636e0d7
commit 80e841a43d

View File

@@ -155,6 +155,19 @@
);
const closeOthersInMultiTab = multiTabIndex =>
closeTabFunc((x, active) => x.tabid != active.tabid && (x.multiTabIndex || 0) == multiTabIndex);
const reopenClosedTab = () => {
const lastClosedTabId = getOpenedTabs()
.filter(x => x.closedTime)
.sort((a, b) => b.closedTime - a.closedTime)[0]?.tabid;
if (!lastClosedTabId) return;
openedTabs.update(x =>
x.map(tab =>
tab.tabid === lastClosedTabId ? { ...tab, selected: true, closedTime: null } : { ...tab, selected: false }
)
);
};
function getTabDbName(tab, connectionList) {
if (tab.tabComponent == 'ConnectionTab') return 'Connections';
@@ -244,6 +257,15 @@
onClick: closeTabsButCurrentDb,
});
registerCommand({
id: 'tabs.reopenClosedTab',
category: 'Tabs',
name: 'Reopen closed tab',
keyText: 'CtrlOrCommand+Shift+T',
testEnabled: () => getOpenedTabs().filter(x => x.closedTime).length >= 1,
onClick: reopenClosedTab,
});
registerCommand({
id: 'tabs.addToFavorites',
category: 'Tabs',