                             @on_redo?(instance, changeObj)
                         if changeObj.origin != 'setValue'
                             @_last_change_time = new Date()
-                            @save_state_debounce?()
+                            @save_state_throttle?()
                             @_syncstring.exit_undo_mode()
                     update_unsaved_uncommitted_changes()
 
                 @emit('connect')   # successful connection
                 cb?()  # done initializing document (this is used, e.g., in the SynchronizedWorksheet derived class).
 
+    # Set value of the syncstring to equal current value of the codemirror editor
     _set_syncstring_to_codemirror: =>
+        if not @_user_action
+            # console.log 'not setting due to no user action'
+            # user has not explicitly done anything, so there should be no changes.
+            return
+        # console.log 'user action so setting'
+        @_user_action = false
         @_last_val = val = @codemirror.getValue()
         @_syncstring.from_str(val)
 
+    # Set value of the codemirror editor to equal current value of the syncstring
     _set_codemirror_to_syncstring: =>
-        val     = @_syncstring.to_str()
-        cur_val = @codemirror.getValue()
-
-        if @_last_val? and cur_val != @_last_val
-            # We *MERGE* the changes in since, we made changes between when we last set
-            # the syncstring and now.  This can perhaps sometimes happen in rare cases
-            # due to async save debouncing.  (Honestly, I don't know how this case could
-            # possibly happen.)
-            patch = syncstring.dmp.patch_make(@_last_val, cur_val)
-            val = syncstring.dmp.patch_apply(patch, val)[0]
-        else
-            patch = undefined
-        @codemirror.setValueNoJump(val)
-        if patch?
-            @_set_syncstring_to_codemirror()
+        @_setting_from_syncstring = true
+        @codemirror.setValueNoJump(@_syncstring.to_str())
+        @_setting_from_syncstring = false
 
     has_unsaved_changes: =>
         if not @codemirror?

            @_set_syncstring_to_codemirror()
        value = @_syncstring.undo().to_str()
        cm.setValueNoJump(value, true)
        @save_state_debounce?()
        @_last_change_time = new Date()

    # per-session sync-aware redo

        @element     = @editor.element

        # window.w = @

        # replace undo/redo by sync-aware versions
        for cm in [@codemirror, @codemirror1]
            cm.undo = @undo
