CaseInsensitiveFileIndex
An O(1) case-insensitive index of the loaded files and folders of a single vault.
The index maps the lowercased path of each abstract file to the abstract file itself. It is kept in sync by an owning component that forwards create/delete/rename vault events.
Import:
import { CaseInsensitiveFileIndex } from 'obsidian-dev-utils/obsidian/case-insensitive-file-index';Signature:
export class CaseInsensitiveFileIndexConstructor
new CaseInsensitiveFileIndex(app: App)Creates a new case-insensitive file index.
Methods
| Method | Returns | Description |
|---|---|---|
| add(abstractFile) | void | Adds an abstract file to the index. |
| delete(path) | void | Removes the abstract file at the given path from the index, along with all of its descendants (for folder deletions, where Obsidian removes the whole subtree). |
| get(path) | null | TAbstractFile | Resolves an abstract file by its path, case-insensitively, in O(1). |
| ownsApp(app) | boolean | Checks whether this index mirrors the given application's vault. |
| rename(oldPath, newAbstractFile) | void | Re-keys an abstract file (and, for folders, all of its descendants) after a rename. Obsidian fires a single rename event for the renamed abstract file and updates its descendants' paths in place without firing per-descendant events, so descendant keys are recomputed here by swapping the old path prefix for the new one. Handles case-only renames (the old and new keys coincide). |
Links to this page: