From c76b45206bd781f8ea0350af5e00a5000b872c5a Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 14 May 2015 01:03:34 +0200 Subject: [PATCH] Use TokenIterator to compute horizontal pixel positions Instead of the TokenizedLine::tokens shim --- src/text-editor-presenter.coffee | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index d5e8fc09c..9be8e9bc0 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -2,6 +2,7 @@ {Point, Range} = require 'text-buffer' _ = require 'underscore-plus' Decoration = require './decoration' +TokenIterator = require './token-iterator' module.exports = class TextEditorPresenter @@ -980,17 +981,20 @@ class TextEditorPresenter top = targetRow * @lineHeight left = 0 column = 0 - for token in @model.tokenizedLineForScreenRow(targetRow).tokens - characterWidths = @getScopedCharacterWidths(token.scopes) + + iterator = TokenIterator.instance.reset(@model.tokenizedLineForScreenRow(targetRow)) + while iterator.next() + characterWidths = @getScopedCharacterWidths(iterator.getScopes()) valueIndex = 0 - while valueIndex < token.value.length - if token.hasPairedCharacter - char = token.value.substr(valueIndex, 2) + text = iterator.getText() + while valueIndex < text.length + if iterator.isPairedCharacter() + char = text charLength = 2 valueIndex += 2 else - char = token.value[valueIndex] + char = text[valueIndex] charLength = 1 valueIndex++