diff --git a/src/editor-component.coffee b/src/editor-component.coffee index 7953af570..ea2a7f5ec 100644 --- a/src/editor-component.coffee +++ b/src/editor-component.coffee @@ -295,8 +295,8 @@ EditorComponent = React.createClass else continue if decorationParams.onlyEmpty - decorationsByScreenRow[screenRow] ?= [] - decorationsByScreenRow[screenRow].push decorationParams + decorationsByScreenRow[screenRow] ?= {} + decorationsByScreenRow[screenRow][decoration.id] = decorationParams decorationsByScreenRow diff --git a/src/gutter-component.coffee b/src/gutter-component.coffee index cf2f5e486..4a88ac3fa 100644 --- a/src/gutter-component.coffee +++ b/src/gutter-component.coffee @@ -154,7 +154,7 @@ GutterComponent = React.createClass classes = '' if lineDecorations? and decorations = lineDecorations[screenRow] - for decoration in decorations + for id, decoration of decorations if Decoration.isType(decoration, 'gutter') classes += decoration.class + ' ' @@ -186,12 +186,13 @@ GutterComponent = React.createClass previousDecorations = @renderedDecorationsByLineNumberId[lineNumberId] if previousDecorations? - for decoration in previousDecorations - node.classList.remove(decoration.class) if Decoration.isType(decoration, 'gutter') and not _.deepContains(decorations, decoration) + for id, decoration of previousDecorations + if Decoration.isType(decoration, 'gutter') and not @hasDecoration(decorations, decoration) + node.classList.remove(decoration.class) if decorations? - for decoration in decorations - if Decoration.isType(decoration, 'gutter') and not _.deepContains(previousDecorations, decoration) + for id, decoration of decorations + if Decoration.isType(decoration, 'gutter') and not @hasDecoration(previousDecorations, decoration) node.classList.add(decoration.class) unless @screenRowsByLineNumberId[lineNumberId] is screenRow @@ -201,6 +202,9 @@ GutterComponent = React.createClass @screenRowsByLineNumberId[lineNumberId] = screenRow @lineNumberIdsByScreenRow[screenRow] = lineNumberId + hasDecoration: (decorations, decoration) -> + decorations? and decorations[decoration.id] == decoration + hasLineNumberNode: (lineNumberId) -> @lineNumberNodesById.hasOwnProperty(lineNumberId) diff --git a/src/lines-component.coffee b/src/lines-component.coffee index 06d598bf2..1ecc12e3a 100644 --- a/src/lines-component.coffee +++ b/src/lines-component.coffee @@ -135,7 +135,7 @@ LinesComponent = React.createClass classes = '' if decorations = lineDecorations[screenRow] - for decoration in decorations + for id, decoration of decorations if Decoration.isType(decoration, 'line') classes += decoration.class + ' ' classes += 'line' @@ -240,12 +240,13 @@ LinesComponent = React.createClass previousDecorations = @renderedDecorationsByLineId[line.id] if previousDecorations? - for decoration in previousDecorations - lineNode.classList.remove(decoration.class) if Decoration.isType(decoration, 'line') and not _.deepContains(decorations, decoration) + for id, decoration of previousDecorations + if Decoration.isType(decoration, 'line') and not @hasDecoration(decorations, decoration) + lineNode.classList.remove(decoration.class) if decorations? - for decoration in decorations - if Decoration.isType(decoration, 'line') and not _.deepContains(previousDecorations, decoration) + for id, decoration of decorations + if Decoration.isType(decoration, 'line') and not @hasDecoration(previousDecorations, decoration) lineNode.classList.add(decoration.class) lineNode.style.width = lineWidth + 'px' if updateWidth @@ -256,6 +257,9 @@ LinesComponent = React.createClass @screenRowsByLineId[line.id] = screenRow @lineIdsByScreenRow[screenRow] = line.id + hasDecoration: (decorations, decoration) -> + decorations? and decorations[decoration.id] == decoration + lineNodeForScreenRow: (screenRow) -> @lineNodesByLineId[@lineIdsByScreenRow[screenRow]]