mirror of
https://github.com/atom/atom.git
synced 2026-01-24 22:38:20 -05:00
Better rows per page calculation
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user