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

@@ -88,6 +88,21 @@ describe('refreshPulledVaultState', () => {
expect(options.closeAllTabs).not.toHaveBeenCalled()
})
it('keeps the active tab mounted while the editor is focused', async () => {
const options = makeOptions({
shouldKeepActiveEditorMounted: vi.fn(() => true),
})
await refreshPulledVaultState(options)
expect(options.shouldKeepActiveEditorMounted).toHaveBeenCalledOnce()
expect(options.reloadVault).toHaveBeenCalledOnce()
expect(options.reloadFolders).toHaveBeenCalledOnce()
expect(options.reloadViews).toHaveBeenCalledOnce()
expect(options.replaceActiveTab).not.toHaveBeenCalled()
expect(options.closeAllTabs).not.toHaveBeenCalled()
})
it('skips stale tab replacement when the active note changes during reload', async () => {
let resolveReload!: (entries: VaultEntry[]) => void
let currentActivePath: string | null = '/vault/active.md'