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:
Antonio Scandurra
2015-09-29 15:16:49 +02:00
parent 40e5f264c5
commit e6a72b794c

View File

@@ -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