                     if @_closed
                         return
                     #dbg("got upstream syncstring change: '#{misc.trunc_middle(@_syncstring.get(),400)}'")
-                    @codemirror.setValueNoJump(@_syncstring.get())
+                    @_set_codemirror_to_syncstring()
                     @emit('sync')
 
                 @_syncstring.on 'metadata-change', =>

                @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

                    if @_closed
                        return
                    #console.log("syncstring before change")
                    @_set_syncstring_to_codemirror()

                @_syncstring.on 'deleted', =>
                    if @_closed
