 
     moveToLineEnd: ->
       { x } = @getPosition()
-      @setPosition({ x, y: @parentView.buffer.getLine(x).length })
+      @setPosition({ x, y: @editor().buffer.getLine(x).length })
 
     moveToLineStart: ->
       { x } = @getPosition()

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

    @pre class: 'cursor', style: 'position: absolute;', => @raw '&nbsp;'

  viewProperties:
    editor: ->
      @parentView

    setBuffer: (@buffer) ->
      @buffer.on 'insert', (e) =>
        @setY(@getY() + e.string.length)

    setPosition: (point) ->
      @point = @editor().clipPosition(point)
      @goalY = null
      @updateAbsolutePosition()

