 
                 if @_last_sync?
                     # We have sync'd before.
+                    synced_before = true
                     patch = @dsync_client._compute_edits(@_last_sync, @live())
                 else
+                    # This initialiation is the first sync.
+                    @_last_sync   = DiffSyncDoc(string:resp.content)
+                    synced_before = false
+                    @codemirror.setOption('readOnly', false)
                     @editor._set(resp.content)
                     @codemirror.clearHistory()  # so undo history doesn't start with "empty document"
 
                 @dsync_client = codemirror_diffsync_client(@, resp.content)
 
-                if @_last_sync?
+                if synced_before
                     # applying missed patches to the new upstream version that we just got from the hub.
                     @_apply_patch_to_live(patch)
                     @emit 'sync'
-                else
-                    # This initialiation is the first sync.
-                    @_last_sync   = DiffSyncDoc(string:resp.content)
 
                 @dsync_server = new DiffSyncHub(@)
                 @dsync_client.connect(@dsync_server)

        @sync       = misc.retry_until_success_wrapper(f:@_sync, min_interval:@opts.sync_interval)# logname:'sync')
        @save       = misc.retry_until_success_wrapper(f:@_save) #logname:'save')

        @editor.save = @save
        @codemirror  = @editor.codemirror
        @element     = @editor.element
        @filename    = @editor.filename

        @init_cursorActivity_event()


            else
                @ui_synced(false)
                @editor.init_autosave()
                @sync()
                @codemirror.on 'change', (instance, changeObj) =>
                    #console.log("change #{misc.to_json(changeObj)}")
                    if changeObj.origin?
