mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
fixed changing tabs with ctrl+tab #245
This commit is contained in:
parent
39cb665b32
commit
10b803d901
@ -100,16 +100,35 @@
|
|||||||
return 'icon file';
|
return 'icon file';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function switchTabByOrder(reverse) {
|
||||||
|
const tabs = _.sortBy(
|
||||||
|
get(openedTabs).filter(x => x.closedTime == null),
|
||||||
|
'tabOrder'
|
||||||
|
);
|
||||||
|
if (reverse) tabs.reverse();
|
||||||
|
const selectedTab = tabs.find(x => x.selected);
|
||||||
|
if (!selectedTab) return;
|
||||||
|
const { tabOrder } = selectedTab;
|
||||||
|
const newTab = tabs.filter(x => (reverse ? x.tabOrder < tabOrder : x.tabOrder > tabOrder))[0] || tabs[0];
|
||||||
|
if (newTab) setSelectedTab(newTab.tabid);
|
||||||
|
}
|
||||||
|
|
||||||
registerCommand({
|
registerCommand({
|
||||||
id: 'tabs.nextTab',
|
id: 'tabs.nextTab',
|
||||||
category: 'Tabs',
|
category: 'Tabs',
|
||||||
name: 'Next tab',
|
name: 'Next tab',
|
||||||
keyText: 'Ctrl+Tab',
|
keyText: 'Ctrl+Tab',
|
||||||
testEnabled: () => getOpenedTabs().filter(x => !x.closedTime).length >= 2,
|
testEnabled: () => getOpenedTabs().filter(x => !x.closedTime).length >= 2,
|
||||||
onClick: () => {
|
onClick: () => switchTabByOrder(false),
|
||||||
const tabs = get(openedTabs).filter(x => x.closedTime == null);
|
});
|
||||||
if (tabs.length >= 2) setSelectedTab(tabs[tabs.length - 2].tabid);
|
|
||||||
},
|
registerCommand({
|
||||||
|
id: 'tabs.previousTab',
|
||||||
|
category: 'Tabs',
|
||||||
|
name: 'Previous tab',
|
||||||
|
keyText: 'Ctrl+Shift+Tab',
|
||||||
|
testEnabled: () => getOpenedTabs().filter(x => !x.closedTime).length >= 2,
|
||||||
|
onClick: () => switchTabByOrder(true),
|
||||||
});
|
});
|
||||||
|
|
||||||
registerCommand({
|
registerCommand({
|
||||||
|
Loading…
Reference in New Issue
Block a user