   getValue: -> @tableEditor.getValueAtScreenPosition(@getPosition())
 
   setPosition: (position, resetSelection=true) ->
+    oldPosition = @position
     @position = Point.fromObject(position)
-    @cursorMoved(resetSelection)
+    @cursorMoved(oldPosition, resetSelection)
 
   getRange: ->
     new Range(@position, {

    @moveRight(@tableEditor.getScreenColumnCount() - @position.column - 1)

  pageUp: ->
    newRow = @position.row - atom.config.get('table-edit.pageMovesAmount')
    @position.row = Math.max 0, newRow
    @cursorMoved()

  pageDown: ->
    newRow = @position.row + atom.config.get('table-edit.pageMovesAmount')
    @position.row = Math.min @tableEditor.getLastRowIndex(), newRow
    @cursorMoved()

  pageLeft: ->
    newColumn = @position.column - atom.config.get('table-edit.pageMovesAmount')
    @position.column = Math.max 0, newColumn
    @cursorMoved()

  pageRight: ->
    newColumn = @position.column + atom.config.get('table-edit.pageMovesAmount')
    @position.column = Math.min @tableEditor.getLastColumnIndex(), newColumn
    @cursorMoved()

  cursorMoved: (resetSelection=true) ->
    @selection.resetRangeOnCursor() if resetSelection
    eventObject = cursor: this
    @emitter.emit 'did-change-position', eventObject
    @tableEditor.emitter.emit 'did-change-cursor-position', eventObject

      @position.row = newRow

    @position.column = newColumn
    @cursorMoved(oldPosition)

  moveRight: (delta=1) ->
    oldPosition = @position.copy()
    newColumn = @position.column + delta
    if newColumn >= @tableEditor.getScreenColumnCount()
      newColumn = 0
