 Serializable = require 'serializable'
 {CompositeDisposable, Emitter} = require 'event-kit'
 {Point, Range} = require 'text-buffer'
+Grim = require 'grim'
 TokenizedBuffer = require './tokenized-buffer'
+TokenIterator = require './token-iterator'
 RowMap = require './row-map'
 Fold = require './fold'
 Model = require './model'
 Token = require './token'
 Decoration = require './decoration'
 Marker = require './marker'
-Grim = require 'grim'
 
 class BufferToScreenConversionError extends Error
   constructor: (@message, @metadata) ->

    top = targetRow * @lineHeightInPixels
    left = 0
    column = 0
    for token in @tokenizedLineForScreenRow(targetRow).tokens
      charWidths = @getScopedCharWidths(token.scopes)
      valueIndex = 0
      while valueIndex < token.value.length
        if token.hasPairedCharacter
          char = token.value.substr(valueIndex, 2)
          charLength = 2
          valueIndex += 2
        else
          char = token.value[valueIndex]
          charLength = 1
          valueIndex++



    left = 0
    column = 0

    iterator = TokenIterator.instance.reset(@tokenizedLineForScreenRow(row))
    while iterator.next()
      charWidths = @getScopedCharWidths(iterator.getScopes())
      value = iterator.getText()
      valueIndex = 0
      while valueIndex < value.length
        if iterator.isPairedCharacter()
          char = value
          charLength = 2
          valueIndex += 2
        else
          char = value[valueIndex]
          charLength = 1
          valueIndex++

