Skip to content

smelt.diff

Availability: Everywhere, including headless mode.

Advanced: Low-level building block for plugins that need full control. It may change more freely than the rest of the API.

Compact unified-patch indexing, metadata and expandable context folds. Rendering cost is proportional to the viewport, not patch length.

smelt.diff.parse

fun(patch: string, context: integer?): smelt.diff.Diff

Types: smelt.diff.Diff

Index Git patch rows and folds without tokenizing source. context defaults to 3 visible lines at each edge of an unchanged run. Row indexing is linear and synchronous; use smelt.git.diff for asynchronous repository acquisition. Syntax and inline highlights are computed on demand in a background worker with bounded caches and old/new parser checkpoints. Each visible window submits its own demand; copying and searching only read cached results. Inline results publish before distant syntax seeks; large replacement blocks compare only viewport pairs. The first 128-256 rows of the previous and next file are prefetched after visible work, without keeping the UI repainting. Text and navigation are immediately available; highlights appear when ready without blocking a frame.