 
     overshoot = position.column - lastSourcePosition.column
     lastPosition.column += overshoot
-    @transformDelegate.reset(lastPosition, position)
+    @transformBuffer.reset(lastPosition, position)
     @position = lastPosition
     @sourcePosition = position
 

  getSourcePosition: ->
    @sourcePosition

class TransformDelegate
  constructor: (@sourceIterator) ->
    @reset(Point.zero(), Point.zero())

  reset: (position, sourcePosition) ->
    @position = position
    @sourcePosition = sourcePosition
    @bufferedOutputs = []
    @bufferedSourceOutput = null
    @sourceIterator.seek(sourcePosition)

  read: =>
    @bufferedSourceOutput or= @sourceIterator.next().value

  consume: (count) =>
    @sourcePosition.column += count
    @bufferedSourceOutput = @bufferedSourceOutput.substring(count)

  produce: (output) =>
    switch output

      lastSourcePosition.column += overshoot
      @position = position
      @sourcePosition = lastSourcePosition
    @transformBuffer.reset(@position, @sourcePosition)

  seekToSourcePosition: (position) ->
    @position = Point.zero()
    @sourcePosition = Point.zero()
    @transformBuffer.reset(@position, @sourcePosition)
    return if position.isZero()

    until @sourcePosition.compare(position) >= 0
