fix(editor): preserve focus during vault refresh

This commit is contained in:
lucaronin
2026-05-05 02:00:28 +02:00
parent 75a8444b41
commit 92c0b895dc
4 changed files with 47 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ interface PulledVaultRefreshOptions {
getActiveTabPath?: () => string | null
closeAllTabs: () => void
hasUnsavedChanges: (path: string) => boolean
shouldKeepActiveEditorMounted?: () => boolean
reloadFolders: () => Promise<unknown> | unknown
reloadVault: () => Promise<VaultEntry[]>
reloadViews: () => Promise<unknown> | unknown
@@ -33,6 +34,7 @@ export async function refreshPulledVaultState(options: PulledVaultRefreshOptions
closeAllTabs,
getActiveTabPath,
hasUnsavedChanges,
shouldKeepActiveEditorMounted,
reloadFolders,
reloadVault,
reloadViews,
@@ -51,6 +53,7 @@ export async function refreshPulledVaultState(options: PulledVaultRefreshOptions
if (!activeTabPath || !latestActiveTabPath) return entries
if (didActivePathChange(activeTabPath, latestActiveTabPath)) return entries
if (hasUnsavedChanges(latestActiveTabPath)) return entries
if (shouldKeepActiveEditorMounted?.()) return entries
const refreshedEntry = findByNotePath(entries, latestActiveTabPath)
if (!refreshedEntry) {