     this.buildLines()
 
   appendLine: (lineNode) ->
-    line = new Tandem.Line(this, lineNode)
-    @lines.append(line)
-    @lineMap[line.id] = line
-    @length += line.length
-    @length += 1 if @lines.length > 1
-    return line
+    return this.insertLineBefore(lineNode, null)
 
   buildLines: ->
     this.reset()

    [lineNode1, lineNode2] = Tandem.Utils.splitNode(line.node, offset, true)
    line.node = lineNode1
    this.updateLine(line)
    newLine = new Tandem.Line(this, lineNode2)
    @lines.insertAfter(line, newLine)
    @lineMap[newLine.id] = newLine
    @length += 1

  toDelta: ->
    lines = @lines.toArray()


  insertLineBefore: (newLineNode, refLine) ->
    line = new Tandem.Line(this, newLineNode)
    if refLine != null
      @lines.insertAfter(refLine.prev, line)
    else
      @lines.append(line)
    @lineMap[line.id] = line
    @length += line.length
    @length += 1 if @lines.length > 1
