mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Don't update top positions of lines/lineNodes unless they have changed
This commit is contained in:
@@ -22,6 +22,7 @@ GutterComponent = React.createClass
|
||||
|
||||
componentWillMount: ->
|
||||
@lineNumberNodesById = {}
|
||||
@lineNumberNodeTopPositions = {}
|
||||
|
||||
# Only update the gutter if the visible row range has changed or if a
|
||||
# non-zero-delta change to the screen lines has occurred within the current
|
||||
@@ -76,6 +77,7 @@ GutterComponent = React.createClass
|
||||
newLineNumbersHTML ?= ""
|
||||
newLineNumberIds.push(id)
|
||||
newLineNumbersHTML += @buildLineNumberHTML(bufferRow, wrapCount > 0, maxLineNumberDigits, top)
|
||||
@lineNumberNodeTopPositions[id] = top
|
||||
|
||||
if newLineNumberIds?
|
||||
WrapperDiv.innerHTML = newLineNumbersHTML
|
||||
@@ -93,6 +95,7 @@ GutterComponent = React.createClass
|
||||
node = @refs.lineNumbers.getDOMNode()
|
||||
for id, lineNumberNode of @lineNumberNodesById when not visibleLineNumberIds.has(id)
|
||||
delete @lineNumberNodesById[id]
|
||||
delete @lineNumberNodeTopPositions[id]
|
||||
node.removeChild(lineNumberNode)
|
||||
|
||||
buildLineNumberHTML: (bufferRow, softWrapped, maxLineNumberDigits, top) ->
|
||||
@@ -109,7 +112,9 @@ GutterComponent = React.createClass
|
||||
"<div class=\"line-number editor-colors\" style=\"top: #{top}px;\">#{innerHTML}</div>"
|
||||
|
||||
updateLineNumberNode: (lineNumberId, top) ->
|
||||
@lineNumberNodesById[lineNumberId].style.top = top + 'px'
|
||||
unless @lineNumberNodeTopPositions[lineNumberId] is top
|
||||
@lineNumberNodesById[lineNumberId].style.top = top + 'px'
|
||||
@lineNumberNodeTopPositions[lineNumberId] = top
|
||||
|
||||
hasLineNumberNode: (lineNumberId) ->
|
||||
@lineNumberNodesById.hasOwnProperty(lineNumberId)
|
||||
|
||||
@@ -27,6 +27,7 @@ LinesComponent = React.createClass
|
||||
componentWillMount: ->
|
||||
@measuredLines = new WeakSet
|
||||
@lineNodesByLineId = {}
|
||||
@lineNodeTopPositions = {}
|
||||
|
||||
componentDidMount: ->
|
||||
@measureLineHeightAndCharWidth()
|
||||
@@ -63,6 +64,7 @@ LinesComponent = React.createClass
|
||||
node = @getDOMNode()
|
||||
for lineId, lineNode of @lineNodesByLineId when not visibleLineIds.has(lineId)
|
||||
delete @lineNodesByLineId[lineId]
|
||||
delete @lineNodeTopPositions[lineId]
|
||||
node.removeChild(lineNode)
|
||||
|
||||
appendOrUpdateVisibleLineNodes: (visibleLines, startRow) ->
|
||||
@@ -81,6 +83,7 @@ LinesComponent = React.createClass
|
||||
newLinesHTML ?= ""
|
||||
newLines.push(line)
|
||||
newLinesHTML += @buildLineHTML(line, top)
|
||||
@lineNodeTopPositions[line.id] = top
|
||||
|
||||
return unless newLines?
|
||||
|
||||
@@ -152,9 +155,11 @@ LinesComponent = React.createClass
|
||||
scopeStack.push(scope)
|
||||
"<span class=\"#{scope.replace(/\.+/g, ' ')}\">"
|
||||
|
||||
updateLineNode: (tokenizedLine, top) ->
|
||||
lineNode = @lineNodesByLineId[tokenizedLine.id]
|
||||
lineNode.style.top = top + 'px'
|
||||
updateLineNode: (line, top) ->
|
||||
unless @lineNodeTopPositions[line.id] is top
|
||||
lineNode = @lineNodesByLineId[line.id]
|
||||
lineNode.style.top = top + 'px'
|
||||
@lineNodeTopPositions[line.id] = top
|
||||
|
||||
measureLineHeightAndCharWidth: ->
|
||||
node = @getDOMNode()
|
||||
|
||||
Reference in New Issue
Block a user