Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Throw exceptions when decorating destroyed marker layers #13817

Merged
merged 1 commit into from
Feb 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion spec/decoration-manager-spec.coffee
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
DecorationManager = require '../src/decoration-manager'

describe "DecorationManager", ->
[decorationManager, buffer, defaultMarkerLayer] = []
[decorationManager, buffer, defaultMarkerLayer, displayLayer] = []

beforeEach ->
buffer = atom.project.bufferForPathSync('sample.js')
Expand Down Expand Up @@ -45,6 +45,13 @@ describe "DecorationManager", ->
).toThrow("Cannot decorate a destroyed marker")
expect(decorationManager.getOverlayDecorations()).toEqual []

it "does not allow destroyed marker layers to be decorated", ->
layer = displayLayer.addMarkerLayer()
layer.destroy()
expect(->
decorationManager.decorateMarkerLayer(layer, {type: 'highlight'})
).toThrow("Cannot decorate a destroyed marker layer")

describe "when a decoration is updated via Decoration::update()", ->
it "emits an 'updated' event containing the new and old params", ->
decoration.onDidChangeProperties updatedSpy = jasmine.createSpy()
Expand Down
1 change: 1 addition & 0 deletions src/decoration-manager.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class DecorationManager extends Model
decoration

decorateMarkerLayer: (markerLayer, decorationParams) ->
throw new Error("Cannot decorate a destroyed marker layer") if markerLayer.isDestroyed()
decoration = new LayerDecoration(markerLayer, this, decorationParams)
@layerDecorationsByMarkerLayerId[markerLayer.id] ?= []
@layerDecorationsByMarkerLayerId[markerLayer.id].push(decoration)
Expand Down