Allow scrollPastEnd to be set from the editor

This commit is contained in:
Antonio Scandurra
2016-06-30 15:05:21 +02:00
parent 7beafa2da6
commit c769b169aa
6 changed files with 60 additions and 29 deletions

View File

@@ -647,17 +647,6 @@ describe "TextEditorPresenter", ->
expectStateUpdate presenter, -> atom.config.set("editor.scrollPastEnd", false)
expect(getState(presenter).verticalScrollbar.scrollHeight).toBe presenter.contentHeight
it "doesn't add the computed clientHeight to the computed scrollHeight if editor.scrollPastEnd is true but the presenter is created with scrollPastEnd as false", ->
presenter = buildPresenter(scrollTop: 10, explicitHeight: 50, horizontalScrollbarHeight: 10, scrollPastEnd: false)
expectStateUpdate presenter, -> presenter.setScrollTop(300)
expect(getState(presenter).verticalScrollbar.scrollHeight).toBe presenter.contentHeight
expectStateUpdate presenter, -> atom.config.set("editor.scrollPastEnd", true)
expect(getState(presenter).verticalScrollbar.scrollHeight).toBe presenter.contentHeight
expectStateUpdate presenter, -> atom.config.set("editor.scrollPastEnd", false)
expect(getState(presenter).verticalScrollbar.scrollHeight).toBe presenter.contentHeight
describe ".scrollTop", ->
it "tracks the value of ::scrollTop", ->
presenter = buildPresenter(scrollTop: 10, explicitHeight: 20, horizontalScrollbarHeight: 10)

View File

@@ -5689,6 +5689,40 @@ describe "TextEditor", ->
editor.selectPageUp()
expect(editor.getSelectedBufferRanges()).toEqual [[[0, 0], [12, 2]]]
describe "scroll past end", ->
it "returns the scrollPastEnd setting on the editor instance if set, or 'editor.scrollPastEnd' otherwise", ->
atom.config.set('editor.scrollPastEnd', true)
expect(editor.getScrollPastEnd()).toBe(true)
atom.config.set('editor.scrollPastEnd', false)
expect(editor.getScrollPastEnd()).toBe(false)
editor.setScrollPastEnd(true)
expect(editor.getScrollPastEnd()).toBe(true)
atom.config.set('editor.scrollPastEnd', true)
atom.config.set('editor.scrollPastEnd', false)
expect(editor.getScrollPastEnd()).toBe(true)
it "emits a onDidChangeScrollPastEnd event when it changes", ->
scrollPastEndSpy = jasmine.createSpy('onDidChangeScrollPastEnd')
editor.onDidChangeScrollPastEnd(scrollPastEndSpy)
atom.config.set('editor.scrollPastEnd', true)
expect(scrollPastEndSpy).toHaveBeenCalled()
scrollPastEndSpy.reset()
editor.setScrollPastEnd(false)
expect(scrollPastEndSpy).toHaveBeenCalled()
scrollPastEndSpy.reset()
editor.setScrollPastEnd(false)
expect(scrollPastEndSpy).not.toHaveBeenCalled()
atom.config.set('editor.scrollPastEnd', false)
atom.config.set('editor.scrollPastEnd', true)
expect(scrollPastEndSpy).not.toHaveBeenCalled()
describe "::setFirstVisibleScreenRow() and ::getFirstVisibleScreenRow()", ->
beforeEach ->
line = Array(9).join('0123456789')