Handle changing ::lineHeight in TextEditorPresenter

This commit is contained in:
Nathan Sobo 2015-01-19 11:44:31 -07:00
parent 9c2ed478cd
commit 5a2bbc945b
2 changed files with 43 additions and 0 deletions

View File

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

View File

@ -51,3 +51,6 @@ class TextEditorPresenter
setClientHeight: (@clientHeight) ->
@updateLinesState()
setLineHeight: (@lineHeight) ->
@updateLinesState()