From e2693da22542e6102fe5c3d0940fc63a6401c3ee Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 19 Jan 2015 16:28:50 -0700 Subject: [PATCH] Fix endRow calculation --- spec/text-editor-presenter-spec.coffee | 2 +- src/text-editor-presenter.coffee | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/spec/text-editor-presenter-spec.coffee b/spec/text-editor-presenter-spec.coffee index f4f969bbd..878a7d603 100644 --- a/spec/text-editor-presenter-spec.coffee +++ b/spec/text-editor-presenter-spec.coffee @@ -168,7 +168,7 @@ describe "TextEditorPresenter", -> describe "when ::clientHeight changes", -> it "updates the lines that are visible on screen", -> - presenter = new TextEditorPresenter(model: editor, clientHeight: 25, scrollTop: 15, lineHeight: 10, lineOverdrawMargin: 1) + presenter = new TextEditorPresenter(model: editor, clientHeight: 15, scrollTop: 15, lineHeight: 10, lineOverdrawMargin: 1) line5 = editor.tokenizedLineForScreenRow(5) expect(presenter.state.lines[line5.id]).toBeUndefined() diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index c58acfff1..90a267b81 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -58,10 +58,9 @@ class TextEditorPresenter Math.max(0, startRow) getEndRow: -> - startRow = @getStartRow() + startRow = Math.floor(@getScrollTop() / @getLineHeight()) visibleLinesCount = Math.ceil(@getClientHeight() / @getLineHeight()) + 1 - overdrawMargin = @lineOverdrawMargin + Math.min(@lineOverdrawMargin, startRow) - endRow = startRow + visibleLinesCount + overdrawMargin + endRow = startRow + visibleLinesCount + @lineOverdrawMargin Math.min(@model.getScreenLineCount(), endRow) getScrollWidth: ->