diff --git a/spec/text-editor-presenter-spec.coffee b/spec/text-editor-presenter-spec.coffee index ef8f2f784..d9f558187 100644 --- a/spec/text-editor-presenter-spec.coffee +++ b/spec/text-editor-presenter-spec.coffee @@ -2040,6 +2040,10 @@ describe "TextEditorPresenter", -> presenter.getState() # trigger state update expect(editor.getRowsPerPage()).toBe(10) + presenter.setLineHeight(5) + presenter.getState() # trigger state update + expect(editor.getRowsPerPage()).toBe(20) + it "tracks the computed content height if ::autoHeight is true so the editor auto-expands vertically", -> presenter = buildPresenter(explicitHeight: null, autoHeight: true) expect(presenter.getState().height).toBe editor.getScreenLineCount() * 10 diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index 4cc119d41..3d4ba6a36 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -72,6 +72,7 @@ class TextEditorPresenter @updateScrollPosition() @updateStartRow() @updateEndRow() + @updateRowsPerPage() @updateCommonGutterState() @updateReflowState() @@ -641,6 +642,12 @@ class TextEditorPresenter endRow = startRow + visibleLinesCount @endRow = Math.min(@model.getScreenLineCount(), endRow) + updateRowsPerPage: -> + rowsPerPage = Math.floor(@getClientHeight() / @lineHeight) + if rowsPerPage isnt @rowsPerPage + @rowsPerPage = rowsPerPage + @model.setRowsPerPage(@rowsPerPage) + updateScrollWidth: -> return unless @contentWidth? and @clientWidth? @@ -688,7 +695,6 @@ class TextEditorPresenter clientHeight = @height - @horizontalScrollbarHeight @model.setHeight(clientHeight, true) - @model.setRowsPerPage(Math.floor(clientHeight / @lineHeight)) unless @clientHeight is clientHeight @clientHeight = clientHeight