Skip to main content

Module autoread

Module autoread 

Source
Expand description

Autoread — external-change detection + refresh for file-backed Document buffers (vim’s autoread).

See docs/dev/architecture/autoread.md for the design and docs/dev/operations/slice-plans/autoread.md (AR.*) for sequencing.

AR.0 (this file, first slice) lands the on-disk fingerprint only — the seam every later slice gates on. No watcher yet. The fingerprint is stamped when a buffer loads and after the editor’s own :w; the live notify watcher (AR.2) compares an incoming filesystem event’s post-read fingerprint against the stored one to (a) suppress the event its own save produced and (b) skip no-op touches.

Structs§

AutoreadChange
A detected external change to a watched file. Emitted by the watcher task, drained by the host, which maps path back to a BufferId.
AutoreadWatcherHandle
Handle held by Editor. Cheap to own; sends are non-blocking. Drop it (or send Shutdown) to tear the task down — the watcher drops and every OS watch is released.
OnDiskFingerprint
The on-disk identity of a file-backed buffer at the moment the editor last synced with disk — a load, or its own :w.

Enums§

AutoreadChangeKind
What kind of external change the watcher detected for a file.
AutoreadWatcherCommand
Editor → watcher-task control commands.

Functions§

classify_autoread
Classify a notify event for autoread. Create/Modify ⇒ Modified; Remove ⇒ Deleted; access/other ⇒ ignored. The classification is only a hint — the host re-stats on receipt, so a rename mis-labelled Modified still resolves correctly (the host finds the file missing and treats it as a delete).
spawn_autoread_watcher_task
Spawn the autoread watcher task on the LSP runtime. Returns the handle Editor keeps plus the change receiver the host drains (AR.4). Err only if notify itself fails to construct the OS watcher.