Handle changing ::clientHeight in TextEditorPresenter

This commit is contained in:
Nathan Sobo 2015-01-19 11:37:17 -07:00
parent 880e1ce1f0
commit 9c2ed478cd
2 changed files with 46 additions and 0 deletions

View File

@ -114,3 +114,46 @@ describe "TextEditorPresenter", ->
tokens: line4.tokens
top: 10 * 4
}
describe "when ::clientHeight changes", ->
it "updates the lines that are visible on screen", ->
presenter = new TextEditorPresenter(model: editor, clientHeight: 25, scrollTop: 25, lineHeight: 10, lineOverdrawMargin: 1)
line5 = editor.tokenizedLineForScreenRow(5)
expect(presenter.state.lines[line5.id]).toBeUndefined()
presenter.setClientHeight(35)
line1 = editor.tokenizedLineForScreenRow(1)
expectValues presenter.state.lines[line1.id], {
screenRow: 1
tokens: line1.tokens
top: 10 * 1
}
line2 = editor.tokenizedLineForScreenRow(2)
expectValues presenter.state.lines[line2.id], {
screenRow: 2
tokens: line2.tokens
top: 10 * 2
}
line3 = editor.tokenizedLineForScreenRow(3)
expectValues presenter.state.lines[line3.id], {
screenRow: 3
tokens: line3.tokens
top: 10 * 3
}
line4 = editor.tokenizedLineForScreenRow(4)
expectValues presenter.state.lines[line4.id], {
screenRow: 4
tokens: line4.tokens
top: 10 * 4
}
expectValues presenter.state.lines[line4.id], {
screenRow: 4
tokens: line4.tokens
top: 10 * 4
}

View File

@ -48,3 +48,6 @@ class TextEditorPresenter
setScrollTop: (@scrollTop) ->
@updateLinesState()
setClientHeight: (@clientHeight) ->
@updateLinesState()