From 670123a9f75a5e59ebf65b35a8a8d8894be4a60f Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 17 Mar 2016 09:28:48 +0100 Subject: [PATCH] More fixes in FakeLinesYardstick --- spec/fake-lines-yardstick.coffee | 38 +++++++++++++++----------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/spec/fake-lines-yardstick.coffee b/spec/fake-lines-yardstick.coffee index 288032d84..085ab4bde 100644 --- a/spec/fake-lines-yardstick.coffee +++ b/spec/fake-lines-yardstick.coffee @@ -26,33 +26,31 @@ class FakeLinesYardstick targetRow = screenPosition.row targetColumn = screenPosition.column - baseCharacterWidth = @model.getDefaultCharWidth() top = @lineTopIndex.pixelPositionAfterBlocksForRow(targetRow) left = 0 column = 0 - for {tokens} in @displayLayer.getScreenLines(targetRow, targetRow + 1)[0] - scopes = [] - for {text, closeTags, openTags} in tokens - scopes.splice(scopes.lastIndexOf(closeTag), 1) for closeTag in closeTags - scopes.push(openTag) for openTag in openTags + scopes = [] + for {text, closeTags, openTags} in @displayLayer.getScreenLines(targetRow, targetRow + 1)[0].tokens + scopes.splice(scopes.lastIndexOf(closeTag), 1) for closeTag in closeTags + scopes.push(openTag) for openTag in openTags + characterWidths = @getScopedCharacterWidths(scopes) - characterWidths = @getScopedCharacterWidths(iterator.getScopes()) - valueIndex = 0 - while valueIndex < text.length - if isPairedCharacter(text, valueIndex) - char = text[valueIndex...valueIndex + 2] - charLength = 2 - valueIndex += 2 - else - char = text[valueIndex] - charLength = 1 - valueIndex++ + valueIndex = 0 + while valueIndex < text.length + if isPairedCharacter(text, valueIndex) + char = text[valueIndex...valueIndex + 2] + charLength = 2 + valueIndex += 2 + else + char = text[valueIndex] + charLength = 1 + valueIndex++ - break if column is targetColumn + break if column is targetColumn - left += characterWidths[char] ? baseCharacterWidth unless char is '\0' - column += charLength + left += characterWidths[char] ? @model.getDefaultCharWidth() unless char is '\0' + column += charLength {top, left}