mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-13 08:44:12 +03:00
Account for overdrawMargin of startRow when computing the endRow
This commit is contained in:
parent
143183aa25
commit
2296d2d378
@ -86,6 +86,13 @@ describe "TextEditorPresenter", ->
|
||||
|
||||
# rows beyond the end of the content are not rendered
|
||||
|
||||
it "contains the lines that are visible on screen, plus and minus the overdraw margin", ->
|
||||
presenter = new TextEditorPresenter(model: editor, clientHeight: 25, scrollTop: 50, lineHeight: 10, lineOverdrawMargin: 1)
|
||||
expect(presenter.state.lines[editor.tokenizedLineForScreenRow(3).id]).toBeUndefined()
|
||||
expect(presenter.state.lines[editor.tokenizedLineForScreenRow(4).id]).toBeDefined()
|
||||
expect(presenter.state.lines[editor.tokenizedLineForScreenRow(9).id]).toBeDefined()
|
||||
expect(presenter.state.lines[editor.tokenizedLineForScreenRow(10).id]).toBeUndefined()
|
||||
|
||||
it "uses the computed scrollWidth as the length of each line", ->
|
||||
line0 = editor.tokenizedLineForScreenRow(0)
|
||||
line1 = editor.tokenizedLineForScreenRow(1)
|
||||
|
@ -56,7 +56,10 @@ class TextEditorPresenter
|
||||
Math.max(0, startRow)
|
||||
|
||||
getEndRow: ->
|
||||
endRow = @getStartRow() + Math.ceil(@clientHeight / @lineHeight) + 1 + @lineOverdrawMargin
|
||||
startRow = @getStartRow()
|
||||
visibleLinesCount = Math.ceil(@clientHeight / @lineHeight) + 1
|
||||
overdrawMargin = @lineOverdrawMargin + Math.min(@lineOverdrawMargin, startRow)
|
||||
endRow = startRow + visibleLinesCount + overdrawMargin
|
||||
Math.min(@model.getScreenLineCount(), endRow)
|
||||
|
||||
getScrollWidth: ->
|
||||
|
Loading…
Reference in New Issue
Block a user