           domPosition++
 
         for i in [intactRange.start..intactRange.end]
+          unless currentLine?
+            console.warn "Unexpected undefined line when clearing dirty range #{intactRange.start}..#{intactRange.end}"
+            return
           currentLine = currentLine.nextSibling
           domPosition++
 

    if intactRanges.length == 0
      @lines[0].innerHTML = ''
    else if currentLine = @lines[0].firstChild
      domPosition = 0
      for intactRange in intactRanges
        while intactRange.domStart > domPosition

    next = lineElement.nextSibling
    @lines[0].removeChild(lineElement)
    next

  fillDirtyRanges: (intactRanges, renderFrom, renderTo) ->
    i = 0
