diff --git a/spec/editor-component-spec.coffee b/spec/editor-component-spec.coffee index 19ca0ccb6..ceca361aa 100644 --- a/spec/editor-component-spec.coffee +++ b/spec/editor-component-spec.coffee @@ -856,6 +856,12 @@ describe "EditorComponent", -> regions = node.querySelectorAll('.test-highlight .region') expect(regions.length).toBe 2 + it "allows the same marker to be decorated with multiple highlights of the same class", -> + editor.addDecorationForMarker(marker, type: 'highlight', class: 'test-highlight') + waitsFor -> not component.decorationChangedImmediate? + runs -> + expect(node.querySelectorAll('.test-highlight').length).toBe 2 + describe "hidden input field", -> it "renders the hidden input field at the position of the last cursor if the cursor is on screen and the editor is focused", -> editor.setVerticalScrollMargin(0) diff --git a/src/decoration.coffee b/src/decoration.coffee index eee0760b1..3c5af12a1 100644 --- a/src/decoration.coffee +++ b/src/decoration.coffee @@ -1,5 +1,7 @@ _ = require 'underscore-plus' +IdCounter = 1 + module.exports = class Decoration @isType: (decoration, decorationType) -> @@ -9,6 +11,7 @@ class Decoration decorationType is decoration.type constructor: (@marker, properties) -> + @id = IdCounter++ _.extend(this, properties) getScreenRange: -> @@ -22,6 +25,7 @@ class Decoration toObject: -> copy = {} + copy.id = @id copy.valid = @isValid() copy.screenRange = @getScreenRange().copy() diff --git a/src/highlights-component.coffee b/src/highlights-component.coffee index 383ad0154..f0f496cba 100644 --- a/src/highlights-component.coffee +++ b/src/highlights-component.coffee @@ -17,7 +17,8 @@ HighlightsComponent = React.createClass for markerId, decorations of highlightDecorations if decorations? for decoration in decorations - highlightComponents.push(HighlightComponent({key: "#{markerId}-#{decoration.class}", decoration, editor, lineHeightInPixels})) + highlightComponents.push(HighlightComponent({key: decoration.id, decoration, editor, lineHeightInPixels})) + highlightComponents shouldComponentUpdate: (newProps) ->