 
     moveRight: ->
       { x, y } = @getPosition()
-      if y < @parentView.buffer.getLine(x).length
+      if y < @editor().buffer.getLine(x).length
         y++
-      else if x < @parentView.buffer.numLines() - 1
+      else if x < @editor().buffer.numLines() - 1
         x++
         y = 0
       @setPosition({x, y})

        y--
      else if x > 0
        x--
        y = @parentView.buffer.getLine(x).length

      @setPosition({x, y})

    updateAbsolutePosition: ->
      position = @parentView.pixelPositionFromPoint(@point)
      @css(position)

      linesInView = @parentView.height() / @height()

      maxScrollMargin = Math.floor((linesInView - 1) / 2)
      scrollMargin = Math.min(@parentView.scrollMargin, maxScrollMargin)
      margin = scrollMargin * @height()
      desiredTop = position.top - margin
      desiredBottom = position.top + @height() + margin

      if desiredBottom > @parentView.scrollBottom()
        @parentView.scrollBottom(desiredBottom)
      else if desiredTop < @parentView.scrollTop()
        @parentView.scrollTop(desiredTop)


    moveDown: ->
      { x, y } = @getPosition()
      y = @goalY if @goalY?
      if x < @editor().buffer.numLines() - 1
        @setPosition({x: x + 1, y: y})
      else
        @moveToLineEnd()
