feat(tabs): add tab navigation history shortcuts
This commit is contained in:
1 parent
c7797b4be1
commit
8213da233b
18 files changed
+406
-17
No files matched your search
@@ -72,6 +72,7 @@ import {
|
||||
isExecuteSqlShortcut,
|
||||
isFocusSearchShortcut,
|
||||
isModRShortcut,
|
||||
handleTabHistoryNavigationShortcut,
|
||||
isNewQueryShortcut,
|
||||
isObjectSourceSaveShortcutTarget,
|
||||
isOpenSettingsShortcut,
|
||||
@@ -88,6 +89,7 @@ import {
|
||||
switchToTabIndexFromShortcut,
|
||||
} from "@/lib/editor/keyboardShortcuts";
|
||||
import { isPreviewTab } from "@/lib/tabs/tabPresentation";
|
||||
import { createTabNavigationHistory, moveInTabNavigationHistory, recordTabVisit } from "@/lib/tabs/tabNavigationHistory";
|
||||
import { supportsSqlFileExecution } from "@/lib/database/databaseCapabilities";
|
||||
import { classifyAiSqlExecution } from "@/lib/ai/aiSqlExecutionPolicy";
|
||||
import { buildAppendedEditorSql } from "@/lib/ai/aiSqlAppend";
|
||||
@@ -287,6 +289,8 @@ const pendingAppCloseAction = ref<AppCloseAction | null>(null);
|
||||
const pendingCloseActionChoice = ref(false);
|
||||
|
||||
const activeTab = computed(() => queryStore.tabs.find((t) => t.id === queryStore.activeTabId));
|
||||
const tabNavigationHistory = ref(createTabNavigationHistory());
|
||||
let pendingTabHistoryNavigationId: string | null = null;
|
||||
|
||||
const externalSqlFileChanges = useExternalSqlFileChanges({
|
||||
activeTab,
|
||||
@@ -725,6 +729,15 @@ watch(
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (id) {
|
||||
if (pendingTabHistoryNavigationId === id) pendingTabHistoryNavigationId = null;
|
||||
else {
|
||||
pendingTabHistoryNavigationId = null;
|
||||
tabNavigationHistory.value = recordTabVisit(tabNavigationHistory.value, id);
|
||||
}
|
||||
} else {
|
||||
pendingTabHistoryNavigationId = null;
|
||||
}
|
||||
if (id) newQueryContextSource.value = "tab";
|
||||
if (id && driverStoreActive.value) driverStoreActive.value = false;
|
||||
if (id && settingsStore.settingsPageActive) settingsStore.settingsPageActive = false;
|
||||
@@ -2236,6 +2249,20 @@ function activateAdjacentTab(direction: -1 | 1): boolean {
|
||||
return activateTabByIndex(nextIndex);
|
||||
}
|
||||
|
||||
function activateTabFromHistory(direction: -1 | 1): boolean {
|
||||
const move = moveInTabNavigationHistory(tabNavigationHistory.value, direction, new Set(queryStore.tabs.map((tab) => tab.id)), queryStore.activeTabId);
|
||||
if (!move) return false;
|
||||
|
||||
const previousHistory = tabNavigationHistory.value;
|
||||
tabNavigationHistory.value = move.history;
|
||||
pendingTabHistoryNavigationId = move.tabId;
|
||||
if (activateQueryTab(move.tabId)) return true;
|
||||
|
||||
tabNavigationHistory.value = previousHistory;
|
||||
pendingTabHistoryNavigationId = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
function handleNativeSelectAll(e: KeyboardEvent) {
|
||||
if (shouldBlockAppNativeSelectAll(e)) e.preventDefault();
|
||||
}
|
||||
@@ -2291,6 +2318,11 @@ async function handleKeydown(e: KeyboardEvent) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (handleTabHistoryNavigationShortcut(e, shortcuts, activateTabFromHistory)) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
return;
|
||||
}
|
||||
if (isSwitchToPreviousTabShortcut(e, shortcuts)) {
|
||||
if (activateAdjacentTab(-1)) {
|
||||
e.preventDefault();
|
||||
|
||||
Reference in new issue
Block a user