mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-11 04:48:44 +03:00
Substract scroll top when paging up
This commit is contained in:
parent
9ba3b74a9d
commit
47ed19f851
@ -1672,6 +1672,7 @@ describe "Editor", ->
|
||||
break
|
||||
row = newRow
|
||||
expect(row).toBe(rows)
|
||||
expect(editor.getLastVisibleScreenRow()).toBe(rows)
|
||||
|
||||
it "moves to the first line when page up is repeated from the last line", ->
|
||||
editor.moveCursorToBottom()
|
||||
@ -1685,6 +1686,7 @@ describe "Editor", ->
|
||||
break
|
||||
row = newRow
|
||||
expect(row).toBe(0)
|
||||
expect(editor.getFirstVisibleScreenRow()).toBe(0)
|
||||
|
||||
it "resets to original position when down is followed by up", ->
|
||||
expect(editor.getCursor().getScreenPosition().row).toBe(0)
|
||||
@ -1692,3 +1694,4 @@ describe "Editor", ->
|
||||
expect(editor.getCursor().getScreenPosition().row).toBeGreaterThan(0)
|
||||
editor.pageUp()
|
||||
expect(editor.getCursor().getScreenPosition().row).toBe(0)
|
||||
expect(editor.getFirstVisibleScreenRow()).toBe(0)
|
||||
|
@ -249,18 +249,15 @@ class Editor extends View
|
||||
stateForScreenRow: (row) -> @activeEditSession.stateForScreenRow(row)
|
||||
|
||||
pageDown: ->
|
||||
[top, rows] = @getPageSize()
|
||||
@activeEditSession.moveCursorDown(rows)
|
||||
@scrollTop(top, adjustVerticalScrollbar: true)
|
||||
newScrollTop = @scrollTop() + @scrollView[0].clientHeight
|
||||
@activeEditSession.moveCursorDown(@getPageRows())
|
||||
@scrollTop(newScrollTop, adjustVerticalScrollbar: true)
|
||||
pageUp: ->
|
||||
[top, rows] = @getPageSize()
|
||||
@activeEditSession.moveCursorUp(rows)
|
||||
@scrollTop(top, adjustVerticalScrollbar: true)
|
||||
getPageSize: ->
|
||||
scrollViewHeight = @scrollView[0].clientHeight
|
||||
newScrollTop = @scrollTop() + scrollViewHeight
|
||||
rows = Math.max(1, Math.ceil(scrollViewHeight / @lineHeight))
|
||||
[newScrollTop, rows]
|
||||
newScrollTop = @scrollTop() - @scrollView[0].clientHeight
|
||||
@activeEditSession.moveCursorUp(@getPageRows())
|
||||
@scrollTop(newScrollTop, adjustVerticalScrollbar: true)
|
||||
getPageRows: ->
|
||||
Math.max(1, Math.ceil(@scrollView[0].clientHeight / @lineHeight))
|
||||
|
||||
setText: (text) -> @getBuffer().setText(text)
|
||||
getText: -> @getBuffer().getText()
|
||||
|
Loading…
Reference in New Issue
Block a user