| Baselines, Myers line diffs, debouncing, undo/redo, and the edge cases behind SavePoint Diff's gutter markers.
I recently shipped SavePoint Diff , a VS Code extension that shows gutter markers for unsaved changes. Here's the design, in case you're thinking about building something similar.
The core idea: a baseline
Everything revolves around one string per file, the baseline , meaning the last saved content.
File opens: capture its content as the baseline.
Edit: diff baseline against the current buffer, then render the result as gutter decorations.
Save: the baseline becomes the new content, and the markers clear.
The diff itself uses a small, well-established Myers line-diff library rather than anything custom.
Debouncing
Diffing on every keystroke is wasteful, so recalculation is delayed until typing pauses.…