         if not @codemirror? or not @_fully_loaded
             cb() # nothing to do -- not initialized/loaded yet...
             return
-        @_syncstring.set(@codemirror.getValue())
+        @_set_syncstring_to_codemirror()
         async.series [@_syncstring.save, @_syncstring.save_to_disk], (err) =>
             @_update_unsaved_uncommitted_changes()
             if err

                @emit('connect')   # successful connection
                cb?()  # done initializing document (this is used, e.g., in the SynchronizedWorksheet derived class).

    has_unsaved_changes: =>
        if not @codemirror?
            return false

            return
        cm = @focused_codemirror()  # see https://github.com/sagemathinc/smc/issues/1161
        if not @_syncstring.in_undo_mode()
            @_set_syncstring_to_codemirror()
        value = @_syncstring.undo()
        cm.setValueNoJump(value, true)
        @save_state_debounce()
