       for token in line.tokens
         w = token.screenDelta
         unless token.isOnlyWhitespace()
-          context.fillStyle = if displayCodeHighlights
+          color = if displayCodeHighlights and @tokenized
             @getTokenColor(token)
           else
             @getDefaultColor()
 
-          chars = 0
-
           value = token.value
           value = value.replace(re, ' ') if re?
 
-          for char in value
-            if /\s/.test char
-              if chars > 0
-                context.fillRect(x-chars, y0, chars*charWidth, charHeight)
-              chars = 0
-            else
-              chars++
-
-            x += charWidth
-
-          if chars > 0
-            context.fillRect(x-chars, y0, chars*charWidth, charHeight)
+          x = @drawToken(context, value, color, x, y0, charWidth, charHeight)
         else
           x += w * charWidth
 


    @subscriptions.add @displayBuffer.onDidTokenize =>
      @tokenized = true
      @requestUpdate()

    if @displayBuffer.tokenizedBuffer.fullyTokenized
      @tokenized = true

  stackChanges: (changes) ->
    @pendingChanges.push changes



    context.fill()

  drawToken: (context, text, color, x, y, charWidth, charHeight) ->
    context.fillStyle = color
    chars = 0
    for char in text
      if /\s/.test char
        if chars > 0
          context.fillRect(x-chars, y, chars*charWidth, charHeight)
        chars = 0
      else
        chars++

      x += charWidth

    context.fillRect(x-chars, y, chars*charWidth, charHeight) if chars > 0

    x

  drawHighlightDecoration: (context, decoration, y, screenRow, lineHeight, charWidth, canvasWidth) ->
    context.fillStyle = @getDecorationColor(decoration)
