     if @stack[source].length > 0
       change = @stack[source].pop()
       @lastRecorded = 0
-      @emittedDelta = change[source]
+      @ignoreChange = true
       @quill.updateContents(change[source], 'user')
-      @emittedDelta = null
+      @ignoreChange = false
       index = this._getLastChangeIndex(change[source])
       @quill.setSelection(index, index)
       @oldDelta = @quill.getContents()


  constructor: (@quill, @options = {}) ->
    @lastRecorded = 0
    @emittedDelta = null
    this.clear()
    this.initListeners()

  initListeners: ->
    @quill.onModuleLoad('keyboard', (keyboard) =>
      keyboard.addHotkey(UndoManager.hotkeys.UNDO, =>
        this.undo()
        return false
      )
      keyboard.addHotkey(UndoManager.hotkeys.REDO, =>
        this.redo()
        return false
      )
    )
    @quill.on(@quill.constructor.events.TEXT_CHANGE, (delta, origin) =>
      return if _.isEqual(delta, @emittedDelta)
      this.record(delta, @oldDelta)
      @oldDelta = @quill.getContents()
    )

      })
      @stack.undo.unshift() if @stack.undo.length > @options.maxStack
    catch ignored
      console.warn('Could not record change... clearing undo stack.')
      this.clear()

  redo: ->
