     # Create a list of new edits, then send all edits not yet
     # processed to the other end of the connection.
     push_edits: (cb) =>
-        edits = {edits:@_compute_edits(@shadow, @live)}
+        snapshot = @_copy(@live)
+        edits = {edits:@_compute_edits(@shadow, snapshot)}
 
         if edits.edits.length > 0
             edits.shadow_version = @shadow_version
             edits.shadow_checksum = @_checksum(@shadow)
             # console.log("#{@id} -- push_edits -- #{misc.to_json(edits)}")
             @edit_stack.push(edits)
-            console.log("#{@id} -- shadow changes: '#{@shadow}' --> '#{@live}'  (version #{@shadow_version+1})")
-            @shadow = @_copy(@live)
+            console.log("#{@id} -- shadow changes: '#{@shadow}' --> '#{snapshot}'  (version #{@shadow_version+1})")
+            @shadow = snapshot
             @shadow_version += 1
         else
             # console.log("#{@id} -- push_edits -- (nothing new)")


        cb?()


exports.test1 = () ->
    client = new DSync(doc:"sage", id:"client")
    server = new DSync(doc:"sage", id:"server")

        console.log(misc.to_json(server.status()))
        console.log("------------------------")

    go = () ->
        client.push_edits( (err) =>
            if not err
                server.push_edits())

    go()
    client.live += "\nmore stuff"
    go()

    client.live = 'bar1\n' + client.live
    server.live = 'bar2\n'
    status()
    while client.live != server.live
        try
            status()
            go()
        catch e
            status()
            break
