mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
Temporarily disable caching from yardstick
This will enable us to avoid worrying about cache invalidation while integrating `LinesYardstick` into `TextEditorPresenter`.
This commit is contained in:
@@ -5,25 +5,12 @@ AcceptFilter = {acceptNode: -> NodeFilter.FILTER_ACCEPT}
|
||||
module.exports =
|
||||
class LinesYardstick
|
||||
constructor: (@model, @presenter, @lineNodesProvider) ->
|
||||
@cachedPositionsByLineId = {}
|
||||
@tokenIterator = new TokenIterator
|
||||
@rangeForMeasurement = document.createRange()
|
||||
|
||||
clearCache: ->
|
||||
@cachedPositionsByLineId = {}
|
||||
|
||||
prepareScreenRowsForMeasurement: (screenRows) ->
|
||||
@presenter.setScreenRowsToMeasure(screenRows)
|
||||
@lineNodesProvider.updateSync(@presenter.getStateForMeasurements())
|
||||
|
||||
cleanup: ->
|
||||
@presenter.clearScreenRowsToMeasure()
|
||||
@lineNodesProvider.updateSync(@presenter.getStateForMeasurements())
|
||||
|
||||
measure: (screenRows, fn) ->
|
||||
@prepareScreenRowsForMeasurement(screenRows)
|
||||
fn()
|
||||
@cleanup()
|
||||
@lineNodesProvider.updateSync(@presenter.getPreMeasurementState())
|
||||
|
||||
pixelPositionForScreenPosition: (screenPosition, clip=true) ->
|
||||
screenPosition = Point.fromObject(screenPosition)
|
||||
@@ -42,9 +29,6 @@ class LinesYardstick
|
||||
tokenizedLine = @model.tokenizedLineForScreenRow(row)
|
||||
return 0 unless tokenizedLine?
|
||||
|
||||
if cachedPosition = @cachedPositionsByLineId[tokenizedLine.id]?[column]
|
||||
return cachedPosition
|
||||
|
||||
lineNode =
|
||||
@lineNodesProvider.lineNodeForLineIdAndScreenRow(tokenizedLine.id, row)
|
||||
|
||||
@@ -91,9 +75,7 @@ class LinesYardstick
|
||||
|
||||
if textNode?
|
||||
foundIndexWithinTextNode ?= textNode.textContent.length
|
||||
@cachedPositionsByLineId[tokenizedLine.id] ?= {}
|
||||
@cachedPositionsByLineId[tokenizedLine.id][column] =
|
||||
@leftPixelPositionForCharInTextNode(lineNode, textNode, foundIndexWithinTextNode)
|
||||
@leftPixelPositionForCharInTextNode(lineNode, textNode, foundIndexWithinTextNode)
|
||||
else
|
||||
0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user