by Dan
Preserves your folded and unfolded blocks and tasks in a note across external file modifications (an AI agent, another program, a git pull or a sync tool) and across quitting and relaunching Obsidian.
Persistent Folded State
An Obsidian plugin that preserves a note's block and task fold states (which headings, lists and tasks are collapsed or expanded) across the kind of external file modification that would normally reset them: an AI agent editing the file, a sync tool, a git pull, or anything else that touches the file outside Obsidian's own editor.
Status: PR-5
Restore is wired in: on a settled external edit, the plugin snapshots the stored anchors for
that note, matches them against the new text (PR-4's matcher), and dispatches tagged CM6 fold
effects for whatever matched — in every open pane, one settle timer and one restore pass per
pane, all reading and writing the one shared FoldStore.
src/fold-restorer.ts— the CM6-level restore pass: snapshots stored anchors at settle time, matches with a real (not no-op) yielding scheduler, dispatches tagged fold effects, and refreshes the note's stored content hash afterwards.src/restore-plan.ts— the pure planning step from (the matcher's own decision, live folded ranges, cursor position, which anchors the store still holds) to (ranges to fold now, ranges deferred until the cursor leaves them).src/describe-fold.ts— now builds a realAnchor(PR-3'sbuildAnchors) instead of PR-2's line-local guess; a PR-2-era raw-text record is discarded on load rather than matched.src/editor-watcher.ts— wires the restore pass into the settle timer and re-checks deferred (cursor-inside) targets on every later update.
Earlier PRs: PR-1 built the persistence layer (src/fold-store.ts) and a minimal UI (the
"Forget stored folds for this note" command, the settings tab's "Forget all stored folds"
button). PR-2 added the editor watcher, fold recording and the settle timer. PR-3 added the pure
anchor builder (src/anchors.ts, src/normalize.ts). PR-4 added the pure matcher
(src/matcher.ts, src/similarity.ts).
Not in this PR: the dormant-fold retry window and first-open baseline adoption (PR-6), restore on reopen/restart/rename/delete (PR-7).
Fold state is per device
Fold state is stored in this plugin's own data.json, which (like every Obsidian plugin's
data.json) is local to the vault on this device and is not synced by Obsidian Sync's settings
sync, nor expected to be portable across devices on its own.
Development
npm install
npm run dev # esbuild watch build
npm run build # typecheck + production build -> main.js
npm run lint # eslint src
npm test # vitest
For plugin developers
Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.