DEV Community

Cover image for Make a Savepoint Before Your Risky Refactor (Without Saving to Disk)
John Wick
John Wick

Posted on

Make a Savepoint Before Your Risky Refactor (Without Saving to Disk)

| How SavePoint Diff's manual savepoints let you diff against "five minutes ago" instead of "my last Ctrl+S".

You're about to do something scary to a file. Rename a core function, restructure a module, rewrite a hot loop.

You don't want to save yet, because the half-finished state might trip a file watcher, a hot-reloader, or a formatter-on-save. But you also don't want to lose your current good-ish state.

Manual savepoints

SavePoint Diff has a command for exactly this:

SavePoint Diff: Create Savepoint (Don't Save to Disk)
Enter fullscreen mode Exit fullscreen mode

It snapshots the active file's current in-memory content as the new diff baseline. Nothing is written to disk. From that moment, the gutter markers and diff view show what you've changed since the savepoint.

A workflow

  1. Your file is in a decent state, unsaved.
  2. Run Create Savepoint.
  3. Start the risky refactor and watch the gutter track every change since the savepoint.
  4. Open the split diff to review, or hover a marker and click ↺ Revert this change to undo one block.
  5. When you're happy, save normally. The baseline moves again.

One thing to know

After a savepoint, SavePoint Diff's surfaces (panel entry, "M" badge, status bar count) show "no differences", because the baseline now matches your buffer. But your file still has unsaved edits on disk terms.

So once you've used a savepoint, trust the editor tab's own ● dirty dot to tell you whether you still need to press Ctrl+S. This is documented in the README's known limitations, and it's worth knowing so it doesn't surprise you.

Want durable checkpoints instead?

There's a second feature for that: named snapshots you can restore later. I cover it in the next post.

Install SavePoint Diff

Top comments (0)