diff --git a/spec/lines-yardstick-spec.coffee b/spec/lines-yardstick-spec.coffee index 72609143e..0cbb6e312 100644 --- a/spec/lines-yardstick-spec.coffee +++ b/spec/lines-yardstick-spec.coffee @@ -155,9 +155,10 @@ describe "LinesYardstick", -> expect(linesYardstick.screenPositionForPixelPosition({top: 28, left: 100})).toEqual([2, 14]) expect(linesYardstick.screenPositionForPixelPosition({top: 32, left: 24.3})).toEqual([2, 3]) expect(linesYardstick.screenPositionForPixelPosition({top: 46, left: 66.5})).toEqual([3, 9]) - expect(linesYardstick.screenPositionForPixelPosition({top: 80, left: 99.9})).toEqual([5, 14]) - expect(linesYardstick.screenPositionForPixelPosition({top: 80, left: 224.2365234375})).toEqual([5, 29]) - expect(linesYardstick.screenPositionForPixelPosition({top: 80, left: 225})).toEqual([5, 30]) + expect(linesYardstick.screenPositionForPixelPosition({top: 70, left: 99.9})).toEqual([5, 14]) + expect(linesYardstick.screenPositionForPixelPosition({top: 70, left: 224.2365234375})).toEqual([5, 29]) + expect(linesYardstick.screenPositionForPixelPosition({top: 70, left: 225})).toEqual([5, 30]) + expect(linesYardstick.screenPositionForPixelPosition({top: 84, left: 247.1})).toEqual([6, 33]) it "clips pixel positions above buffer start", -> expect(linesYardstick.screenPositionForPixelPosition(top: -Infinity, left: -Infinity)).toEqual [0, 0] diff --git a/src/lines-yardstick.coffee b/src/lines-yardstick.coffee index 39e16a8e0..af12242a3 100644 --- a/src/lines-yardstick.coffee +++ b/src/lines-yardstick.coffee @@ -75,6 +75,7 @@ class LinesYardstick characterIndex = nextCharIndex break + characterIndex = textNode.textContent.length if characterIndex is -1 textNodeStartColumn = 0 textNodeStartColumn += textNodes[i].length for i in [0...textNodeIndex] by 1 Point(row, textNodeStartColumn + characterIndex)