Skip to content

Commit

Permalink
fix: add destroyed prop to DecorationManagement
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jan 16, 2021
1 parent b9e351c commit 784732d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/decoration-management.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ export default class DecorationManagement {
* @access private
*/
this.decorationDestroyedSubscriptions = new Map()

// is set to true when a minimapElement is destroyed
this.destroyed = false
}

/**
Expand Down Expand Up @@ -322,7 +325,7 @@ export default class DecorationManagement {
* @emits {did-change} when the decoration is created successfully
*/
decorateMarker (marker, decorationParams) {
if (this.minimap.destroyed || marker == null) { return }
if (this.destroyed || this.minimap.destroyed || marker == null) { return }

const { id } = marker

Expand Down Expand Up @@ -435,7 +438,7 @@ export default class DecorationManagement {
* @access private
*/
emitDecorationChanges (type, decoration) {
if (this.minimap.editorDestroyed()) { return }
if (this.destroyed || this.minimap.editorDestroyed()) { return }

this.invalidateDecorationForScreenRowsCache()

Expand Down Expand Up @@ -535,7 +538,7 @@ export default class DecorationManagement {
for (let i = 0, len = decorations.length; i < len; i++) {
const decoration = decorations[i]

if (!this.minimap.editorDestroyed()) {
if (!this.destroyed && !this.minimap.editorDestroyed()) {
this.emitDecorationChanges(decoration.getProperties().type, decoration)
}
this.emitter.emit('did-remove-decoration', {
Expand Down
1 change: 1 addition & 0 deletions lib/minimap-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ class MinimapElement {
destroy () {
this.subscriptions.dispose()
this.DecorationManagement.removeAllDecorations()
this.DecorationManagement.destroyed = true
this.detach()
this.minimap.minimapElement = null
this.minimap = null
Expand Down

0 comments on commit 784732d

Please sign in to comment.