Skip to content

Commit

Permalink
🐛 Fix issue where decorations were not properly removed from canvas
Browse files Browse the repository at this point in the history
This was due to the fact that before we could register the changes the
decoration's range was already changed, registering an improper range
for a repaint
  • Loading branch information
abe33 committed Aug 9, 2017
1 parent 0583cb5 commit 6c856b9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions lib/decoration.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ module.exports = class Decoration {
this.markerDestroyDisposable = this.marker.onDidDestroy(() => {
this.destroy()
})

this.screenRange = marker.getScreenRange()
}

/**
Expand Down
4 changes: 3 additions & 1 deletion lib/minimap-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,9 @@ class MinimapElement {

this.subscriptions.add(this.minimap.onDidChangeDecorationRange((change) => {
const {type} = change
if (type === 'line' || type === 'highlight-under' || type === 'background-custom') {
if (type === 'line' ||
type === 'highlight-under' ||
type === 'background-custom') {
this.pendingBackDecorationChanges.push(change)
} else {
this.pendingFrontDecorationChanges.push(change)
Expand Down
11 changes: 6 additions & 5 deletions lib/mixins/decoration-management.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ module.exports = class DecorationManagement {
if (this.decorationMarkerChangedSubscriptions[id] == null) {
this.decorationMarkerChangedSubscriptions[id] =
marker.onDidChange((event) => {
let decorations = this.decorationsByMarkerId[id]
const decorations = this.decorationsByMarkerId[id]
const screenRange = marker.getScreenRange()

this.invalidateDecorationForScreenRowsCache()

Expand All @@ -365,6 +366,9 @@ module.exports = class DecorationManagement {
decoration: decoration,
event: event
})
this.emitDecorationChanges(decoration.type, decoration)

decoration.screenRange = screenRange
}
}
let oldStart = event.oldTailScreenPosition
Expand Down Expand Up @@ -479,10 +483,7 @@ module.exports = class DecorationManagement {

this.invalidateDecorationForScreenRowsCache()

const range = {
start: decoration.marker.oldTailScreenPosition,
end: decoration.marker.oldHeadScreenPosition
}
const range = decoration.screenRange
if (!range.start || !range.end) { return }

this.emitRangeChanges(type, range, 0)
Expand Down

0 comments on commit 6c856b9

Please sign in to comment.