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