Skip to content

Commit

Permalink
fix: return destoryed decoration and disposable on fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed May 8, 2021
1 parent f78fa69 commit bd4eb25
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lib/minimap.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import { editorsMinimaps } from "./main"

let nextModelId = 1

// returned in the decorations API when minimap is destoryed
const destoryedDecorationMock = { destroyed: true }
const disposedDisposable = new Disposable()
disposedDisposable.dispose()

/**
* The Minimap class is the underlying model of a <MinimapElement>.
* Most manipulations of the minimap is done through the model.
Expand Down Expand Up @@ -1125,25 +1130,25 @@ export default class Minimap {
return this.getDecorationManagement()?.getDecorations() ?? []
}
onDidAddDecoration(...args) {
return this.getDecorationManagement()?.onDidAddDecoration(...args) ?? new Disposable()
return this.getDecorationManagement()?.onDidAddDecoration(...args) ?? disposedDisposable
}
onDidRemoveDecoration(...args) {
return this.getDecorationManagement()?.onDidRemoveDecoration(...args) ?? new Disposable()
return this.getDecorationManagement()?.onDidRemoveDecoration(...args) ?? disposedDisposable
}
onDidChangeDecorationRange(...args) {
return this.getDecorationManagement()?.onDidChangeDecorationRange(...args) ?? new Disposable()
return this.getDecorationManagement()?.onDidChangeDecorationRange(...args) ?? disposedDisposable
}
onDidUpdateDecoration(...args) {
return this.getDecorationManagement()?.onDidUpdateDecoration(...args) ?? new Disposable()
return this.getDecorationManagement()?.onDidUpdateDecoration(...args) ?? disposedDisposable
}
decorationForId(...args) {
return this.getDecorationManagement()?.decorationForId(...args) ?? {}
return this.getDecorationManagement()?.decorationForId(...args) ?? destoryedDecorationMock
}
decorationsForScreenRowRange(...args) {
return this.getDecorationManagement()?.decorationsForScreenRowRange(...args) ?? {}
return this.getDecorationManagement()?.decorationsForScreenRowRange(...args) ?? destoryedDecorationMock
}
decorationsByTypeThenRows() {
return this.getDecorationManagement()?.decorationsByTypeThenRows() ?? {}
return this.getDecorationManagement()?.decorationsByTypeThenRows() ?? destoryedDecorationMock
}
decorateMarker(...args) {
return this.getDecorationManagement()?.decorateMarker(...args)
Expand Down

0 comments on commit bd4eb25

Please sign in to comment.