🐛 updateContentDimensions when model changes

This commit is contained in:
Antonio Scandurra 2015-07-07 11:28:30 +02:00
parent ed735d80e8
commit 4e4b49eef8
2 changed files with 12 additions and 1 deletions

View File

@ -153,7 +153,6 @@ describe "TextEditorPresenter", ->
expect(stateFn(presenter).tiles[8]).toBeDefined()
expect(stateFn(presenter).tiles[10]).toBeUndefined()
it "updates when ::lineHeight changes", ->
presenter = buildPresenter(explicitHeight: 6, scrollTop: 0, lineHeight: 1, tileSize: 2)
@ -661,6 +660,16 @@ describe "TextEditorPresenter", ->
expectStateUpdate presenter, -> presenter.setScrollTop(50)
expect(presenter.getState().content.scrollTop).toBe 50
it "scrolls down automatically when the model is changed", ->
presenter = buildPresenter(scrollTop: 0, lineHeight: 10, explicitHeight: 20)
editor.setText("")
editor.insertNewline()
expect(presenter.getState().content.scrollTop).toBe(0)
editor.insertNewline()
expect(presenter.getState().content.scrollTop).toBe(10)
it "never exceeds the computed scroll height minus the computed client height", ->
presenter = buildPresenter(scrollTop: 10, lineHeight: 10, explicitHeight: 50, horizontalScrollbarHeight: 10)
expectStateUpdate presenter, -> presenter.setScrollTop(100)

View File

@ -112,6 +112,8 @@ class TextEditorPresenter
observeModel: ->
@disposables.add @model.onDidChange =>
@updateContentDimensions()
@shouldUpdateHeightState = true
@shouldUpdateVerticalScrollState = true
@shouldUpdateHorizontalScrollState = true