Prevent updates for off-screen line decoration markers on change

When there were lots of off-screen markers, we were performing lots of
redundant updates when off-screen markers changed. Now we only perform
updates if they intersect the visible row range.

@maxbrunsfeld this should improve the situation for folding/unfolding
when there are lots of others folds. Let me know.
This commit is contained in:
Nathan Sobo
2015-02-03 21:02:33 -07:00
parent 20a95269c9
commit a685f3dc37

View File

@@ -563,12 +563,27 @@ class TextEditorPresenter
decorationMarkerDidChange: (decoration, change) ->
if decoration.isType('line') or decoration.isType('line-number')
@removeFromLineDecorationCaches(decoration, new Range(change.oldTailScreenPosition, change.oldHeadScreenPosition))
@addToLineDecorationCaches(decoration, new Range(change.newTailScreenPosition, change.newHeadScreenPosition))
@updateLinesState() if decoration.isType('line')
@updateLineNumbersState() if decoration.isType('line-number')
intersectsVisibleRowRange = false
startRow = @computeStartRow()
endRow = @computeEndRow()
oldRange = new Range(change.oldTailScreenPosition, change.oldHeadScreenPosition)
newRange = new Range(change.newTailScreenPosition, change.newHeadScreenPosition)
if oldRange.intersectsRowRange(startRow, endRow - 1)
@removeFromLineDecorationCaches(decoration, oldRange)
intersectsVisibleRowRange = true
if newRange.intersectsRowRange(startRow, endRow - 1)
@addToLineDecorationCaches(decoration, newRange)
intersectsVisibleRowRange = true
if intersectsVisibleRowRange
@updateLinesState() if decoration.isType('line')
@updateLineNumbersState() if decoration.isType('line-number')
if decoration.isType('highlight')
@updateHighlightState(decoration)
if decoration.isType('overlay')
@updateOverlaysState()