Make all lines visible if no external client height is assigned

This commit is contained in:
Nathan Sobo 2015-01-19 15:39:51 -07:00
parent ac463143dd
commit 7095ccd32b
2 changed files with 9 additions and 1 deletions

View File

@ -93,6 +93,11 @@ describe "TextEditorPresenter", ->
expect(presenter.state.lines[editor.tokenizedLineForScreenRow(9).id]).toBeDefined()
expect(presenter.state.lines[editor.tokenizedLineForScreenRow(10).id]).toBeUndefined()
it "reports all lines as visible if no external ::clientHeight is assigned", ->
presenter = new TextEditorPresenter(model: editor, scrollTop: 0, lineHeight: 10, lineOverdrawMargin: 1)
expect(presenter.state.lines[editor.tokenizedLineForScreenRow(0).id]).toBeDefined()
expect(presenter.state.lines[editor.tokenizedLineForScreenRow(12).id]).toBeDefined()
it "uses the computed scrollWidth as the length of each line", ->
line0 = editor.tokenizedLineForScreenRow(0)
line1 = editor.tokenizedLineForScreenRow(1)

View File

@ -58,7 +58,7 @@ class TextEditorPresenter
getEndRow: ->
startRow = @getStartRow()
visibleLinesCount = Math.ceil(@clientHeight / @lineHeight) + 1
visibleLinesCount = Math.ceil(@getClientHeight() / @lineHeight) + 1
overdrawMargin = @lineOverdrawMargin + Math.min(@lineOverdrawMargin, startRow)
endRow = startRow + visibleLinesCount + overdrawMargin
Math.min(@model.getScreenLineCount(), endRow)
@ -74,6 +74,9 @@ class TextEditorPresenter
setClientHeight: (@clientHeight) ->
@updateLinesState()
getClientHeight: ->
@clientHeight ? @model.getScreenLineCount() * @lineHeight
setClientWidth: (@clientWidth) ->
@updateLinesState()