Merge pull request #10062 from atom/mb-emit-state-update-on-model-scroll

Emit state update when model's scroll position is changed
This commit is contained in:
Max Brunsfeld
2015-12-14 17:38:36 -08:00
2 changed files with 6 additions and 1 deletions

View File

@@ -782,6 +782,11 @@ describe "TextEditorPresenter", ->
getState(presenter) # commits scroll position
expect(editor.getFirstVisibleScreenRow()).toBe 6
it "updates when the model's scroll position is changed directly", ->
presenter = buildPresenter(scrollTop: 0, explicitHeight: 20, horizontalScrollbarHeight: 10, lineHeight: 10)
expectStateUpdate presenter, -> editor.setFirstVisibleScreenRow(1)
expect(getState(presenter).content.scrollTop).toBe 10
it "reassigns the scrollTop if it exceeds the max possible value after lines are removed", ->
presenter = buildPresenter(scrollTop: 80, lineHeight: 10, explicitHeight: 50, horizontalScrollbarHeight: 0)
expect(getState(presenter).content.scrollTop).toBe(80)

View File

@@ -1264,7 +1264,7 @@ class TextEditorPresenter
@emitDidUpdateState()
didChangeFirstVisibleScreenRow: (screenRow) ->
@updateScrollTop(screenRow * @lineHeight)
@setScrollTop(screenRow * @lineHeight)
getVerticalScrollMarginInPixels: ->
Math.round(@model.getVerticalScrollMargin() * @lineHeight)