mirror of
https://github.com/atom/atom.git
synced 2026-01-24 22:38:20 -05:00
🐎 Remove rows to measure in the next frame
This commit is contained in:
@@ -33,6 +33,7 @@ describe "LinesYardstick", ->
|
||||
mockPresenter =
|
||||
isBatching: -> true
|
||||
setScreenRowsToMeasure: (screenRows) -> screenRowsToMeasure = screenRows
|
||||
clearScreenRowsToMeasure: -> setScreenRowsToMeasure = []
|
||||
getPreMeasurementState: ->
|
||||
state = {}
|
||||
for screenRow in screenRowsToMeasure
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) ->
|
||||
|
||||
@@ -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?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user