Skip to content

Commit e76876f

Browse files
authored
fix: Optimizations (#53)
1 parent 9c06ba6 commit e76876f

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

lib/minimap-highlight-selected.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,15 @@ module.exports = {
4949
this.highlightSelected.onDidRemoveAllMarkers(() => this.markersDestroyed())
5050
},
5151

52+
destryDecorations () {
53+
for (let i = 0, len = this.decorations.length; i < len; i++) {
54+
this.decorations[i].destroy()
55+
}
56+
},
57+
5258
dispose () {
5359
if (this.decorations) {
54-
this.decorations.forEach(decoration => decoration.destroy())
60+
this.destryDecorations()
5561
}
5662
this.decorations = null
5763
},
@@ -60,17 +66,18 @@ module.exports = {
6066
if (!selected) { selected = false }
6167
const minimap = this.minimap.minimapForEditor(options.editor)
6268
if (!minimap) { return }
63-
let className = 'highlight-selected'
64-
if (selected) { className += ' selected' }
6569

66-
const decoration = minimap.decorateMarker(options.marker,
67-
{ type: 'highlight', class: className })
68-
this.decorations.push(decoration)
70+
this.decorations.push(
71+
minimap.decorateMarker(options.marker, {
72+
type: 'highlight',
73+
class: `highlight-selected${selected ? ' selected' : ''}`,
74+
}),
75+
)
6976
},
7077

7178
markersDestroyed () {
7279
if (this.decorations) {
73-
this.decorations.forEach(decoration => decoration.destroy())
80+
this.destryDecorations()
7481
}
7582
this.decorations = []
7683
},

styles/minimap-highlight-selected.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
@import "ui-variables";
66
@import "syntax-variables";
77

8+
@contain_all: layout size paint style;
9+
810
.minimap .highlight-selected {
11+
contain: @contain_all;
912
background: @text-color-highlight;
1013

1114
&.selected {
15+
contain: @contain_all;
1216
background: fadeout(@text-color-highlight, 50%);
1317
}
1418
}

0 commit comments

Comments
 (0)