🐎 Remove rows to measure in the next frame

This commit is contained in:
Antonio Scandurra
2015-10-02 12:32:59 +02:00
parent 33523751ea
commit 2ffa7da59e
4 changed files with 24 additions and 0 deletions

View File

@@ -33,6 +33,7 @@ describe "LinesYardstick", ->
mockPresenter =
isBatching: -> true
setScreenRowsToMeasure: (screenRows) -> screenRowsToMeasure = screenRows
clearScreenRowsToMeasure: -> setScreenRowsToMeasure = []
getPreMeasurementState: ->
state = {}
for screenRow in screenRowsToMeasure

View File

@@ -114,6 +114,16 @@ describe "TextEditorPresenter", ->
expect(stateFn(presenter).tiles[10]).toBeDefined()
expect(stateFn(presenter).tiles[12]).toBeDefined()
presenter.clearScreenRowsToMeasure()
expect(stateFn(presenter).tiles[0]).toBeDefined()
expect(stateFn(presenter).tiles[2]).toBeDefined()
expect(stateFn(presenter).tiles[4]).toBeDefined()
expect(stateFn(presenter).tiles[6]).toBeDefined()
expect(stateFn(presenter).tiles[8]).toBeUndefined()
expect(stateFn(presenter).tiles[10]).toBeUndefined()
expect(stateFn(presenter).tiles[12]).toBeUndefined()
it "excludes invalid tiles for screen rows to measure", ->
presenter = buildPresenter(explicitHeight: 6, scrollTop: 0, lineHeight: 1, tileSize: 2)
presenter.setScreenRowsToMeasure([20, 30]) # unexisting rows

View File

@@ -17,6 +17,9 @@ class LinesYardstick
@presenter.setScreenRowsToMeasure(screenRows)
@lineNodesProvider.updateSync(@presenter.getPreMeasurementState())
clearScreenRowsForMeasurement: ->
@presenter.clearScreenRowsToMeasure()
screenPositionForPixelPosition: (pixelPosition) ->
targetTop = pixelPosition.top
targetLeft = pixelPosition.left
@@ -75,6 +78,8 @@ class LinesYardstick
previousColumn = column
column += charLength
@clearScreenRowsForMeasurement()
if targetLeft <= previousLeft + (charWidth / 2)
new Point(row, previousColumn)
else
@@ -92,6 +97,8 @@ class LinesYardstick
top = targetRow * @model.getLineHeightInPixels()
left = @leftPixelPositionForScreenPosition(targetRow, targetColumn)
@clearScreenRowsForMeasurement()
{top, left}
leftPixelPositionForScreenPosition: (row, column) ->

View File

@@ -395,6 +395,12 @@ class TextEditorPresenter
@shouldUpdateLineNumbersState = true
@shouldUpdateDecorations = true
clearScreenRowsToMeasure: ->
@screenRowsToMeasure = []
@shouldUpdateLinesState = true
@shouldUpdateLineNumbersState = true
@shouldUpdateDecorations = true
updateTilesState: ->
return unless @startRow? and @endRow? and @lineHeight?