From 14d8ecefdde4d9c2dacb3cfdd9efa13751b24637 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 4 Dec 2015 12:54:20 +0100 Subject: [PATCH] :green_heart: Fix LinesYardstick specs --- spec/lines-yardstick-spec.coffee | 5 ++++- src/lines-yardstick.coffee | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/lines-yardstick-spec.coffee b/spec/lines-yardstick-spec.coffee index fbf5c53bf..44267699e 100644 --- a/spec/lines-yardstick-spec.coffee +++ b/spec/lines-yardstick-spec.coffee @@ -57,7 +57,10 @@ describe "LinesYardstick", -> textNodes editor.setLineHeightInPixels(14) - linesYardstick = new LinesYardstick(editor, mockPresenter, mockLineNodesProvider, new LineTopIndex(), atom.grammars) + lineTopIndex = new LineTopIndex() + lineTopIndex.setDefaultLineHeight(editor.getLineHeightInPixels()) + lineTopIndex.setMaxRow(editor.getScreenLineCount()) + linesYardstick = new LinesYardstick(editor, mockPresenter, mockLineNodesProvider, lineTopIndex, atom.grammars) afterEach -> lineNode.remove() for lineNode in createdLineNodes diff --git a/src/lines-yardstick.coffee b/src/lines-yardstick.coffee index c1faa6399..847ebfd46 100644 --- a/src/lines-yardstick.coffee +++ b/src/lines-yardstick.coffee @@ -25,6 +25,7 @@ class LinesYardstick row = @lineTopIndex.rowForTopPixelPosition(targetTop, 'floor') targetLeft = 0 if targetTop < 0 targetLeft = Infinity if row > @model.getLastScreenRow() + row = Math.min(row, @model.getLastScreenRow()) @prepareScreenRowsForMeasurement([row]) unless measureVisibleLinesOnly