   updateSync: ->
     @oldState ?= {}
     @newState = @presenter.getState()
-
-    cursorMoved = @cursorMoved
-    selectionChanged = @selectionChanged
-    @cursorMoved = false
-    @selectionChanged = false
 
     if @editor.getLastSelection()? and not @editor.getLastSelection().isEmpty()
       @domNode.classList.add('has-selection')

    @sampleBackgroundColors()
    @remeasureCharacterWidths()

  onSelectionAdded: (selection) =>
    selectionDisposables = new CompositeDisposable
    selectionDisposables.add selection.onDidChangeRange => @onSelectionChanged(selection)
    selectionDisposables.add selection.onDidDestroy =>
      @onSelectionChanged(selection)
      selectionDisposables.dispose()
      @disposables.remove(selectionDisposables)

    @disposables.add(selectionDisposables)

    if @editor.selectionIntersectsVisibleRowRange(selection)
      @selectionChanged = true

  onSelectionChanged: (selection) =>
    if @editor.selectionIntersectsVisibleRowRange(selection)
      @selectionChanged = true

  onCursorAdded: (cursor) =>
    @disposables.add cursor.onDidChangePosition @onCursorMoved

  onCursorMoved: =>
    @cursorMoved = true

  handleDragUntilMouseUp: (dragHandler) =>
    dragging = false
    lastMousePosition = {}


  observeEditor: ->
    @disposables.add @editor.observeGrammar(@onGrammarChanged)

  listenForDOMEvents: ->
    @domNode.addEventListener 'mousewheel', @onMouseWheel
