           if entry.isBoundary
             return false
         else
-          for {oldStart, oldExtent, newExtent, oldText, newText} in entry.getChanges()
-            patch.splice(oldStart, newExtent, oldExtent, {oldText: newText, newText: oldText})
+          patch = Patch.invert(entry)
           unless withinGroup
             spliceIndex = i
 

    throw new Error("Didn't find matching group-start entry")

  pushChange: (change) ->
    @undoStack.push(buildPatchFromChange(change))
    @clearRedoStack()

    if @undoStack.length - @maxUndoEntries > 0

Patch = require 'atom-patch'

SerializationVersion = 3

class Checkpoint
  constructor: (@id, @snapshot, @isBoundary) ->
