mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 15:37:46 +03:00
Manually set rows per page in the model
This commit is contained in:
parent
67af264c0d
commit
e648d880ed
@ -2026,6 +2026,20 @@ describe "TextEditorPresenter", ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe ".height", ->
|
describe ".height", ->
|
||||||
|
it "updates model's rows per page when it changes", ->
|
||||||
|
presenter = buildPresenter(explicitHeight: 50, lineHeightInPixels: 10, horizontalScrollbarHeight: 10)
|
||||||
|
|
||||||
|
presenter.getState() # trigger state update
|
||||||
|
expect(editor.getRowsPerPage()).toBe(4)
|
||||||
|
|
||||||
|
presenter.setExplicitHeight(100)
|
||||||
|
presenter.getState() # trigger state update
|
||||||
|
expect(editor.getRowsPerPage()).toBe(9)
|
||||||
|
|
||||||
|
presenter.setHorizontalScrollbarHeight(0)
|
||||||
|
presenter.getState() # trigger state update
|
||||||
|
expect(editor.getRowsPerPage()).toBe(10)
|
||||||
|
|
||||||
it "tracks the computed content height if ::autoHeight is true so the editor auto-expands vertically", ->
|
it "tracks the computed content height if ::autoHeight is true so the editor auto-expands vertically", ->
|
||||||
presenter = buildPresenter(explicitHeight: null, autoHeight: true)
|
presenter = buildPresenter(explicitHeight: null, autoHeight: true)
|
||||||
expect(presenter.getState().height).toBe editor.getScreenLineCount() * 10
|
expect(presenter.getState().height).toBe editor.getScreenLineCount() * 10
|
||||||
|
@ -4365,8 +4365,8 @@ describe "TextEditor", ->
|
|||||||
|
|
||||||
describe ".pageUp/Down()", ->
|
describe ".pageUp/Down()", ->
|
||||||
it "moves the cursor down one page length", ->
|
it "moves the cursor down one page length", ->
|
||||||
editor.setLineHeightInPixels(10)
|
editor.setRowsPerPage(5)
|
||||||
editor.setHeight(50, true)
|
|
||||||
expect(editor.getCursorBufferPosition().row).toBe 0
|
expect(editor.getCursorBufferPosition().row).toBe 0
|
||||||
|
|
||||||
editor.pageDown()
|
editor.pageDown()
|
||||||
@ -4383,8 +4383,8 @@ describe "TextEditor", ->
|
|||||||
|
|
||||||
describe ".selectPageUp/Down()", ->
|
describe ".selectPageUp/Down()", ->
|
||||||
it "selects one screen height of text up or down", ->
|
it "selects one screen height of text up or down", ->
|
||||||
editor.setLineHeightInPixels(10)
|
editor.setRowsPerPage(5)
|
||||||
editor.setHeight(50, true)
|
|
||||||
expect(editor.getCursorBufferPosition().row).toBe 0
|
expect(editor.getCursorBufferPosition().row).toBe 0
|
||||||
|
|
||||||
editor.selectPageDown()
|
editor.selectPageDown()
|
||||||
|
@ -688,6 +688,7 @@ class TextEditorPresenter
|
|||||||
|
|
||||||
clientHeight = @height - @horizontalScrollbarHeight
|
clientHeight = @height - @horizontalScrollbarHeight
|
||||||
@model.setHeight(clientHeight, true)
|
@model.setHeight(clientHeight, true)
|
||||||
|
@model.setRowsPerPage(Math.floor(clientHeight / @lineHeight))
|
||||||
|
|
||||||
unless @clientHeight is clientHeight
|
unless @clientHeight is clientHeight
|
||||||
@clientHeight = clientHeight
|
@clientHeight = clientHeight
|
||||||
|
@ -2895,7 +2895,9 @@ class TextEditor extends Model
|
|||||||
|
|
||||||
# Returns the number of rows per page
|
# Returns the number of rows per page
|
||||||
getRowsPerPage: ->
|
getRowsPerPage: ->
|
||||||
Math.max(1, Math.floor(@getHeight() / @getLineHeightInPixels()))
|
Math.max(@rowsPerPage ? 1, 1)
|
||||||
|
|
||||||
|
setRowsPerPage: (@rowsPerPage) ->
|
||||||
|
|
||||||
###
|
###
|
||||||
Section: Config
|
Section: Config
|
||||||
|
Loading…
Reference in New Issue
Block a user