Skip to content

Commit 0264d0d

Browse files
committed
fix: decaffeinate
1 parent b7e4b6d commit 0264d0d

File tree

4 files changed

+112
-84
lines changed

4 files changed

+112
-84
lines changed

lib/minimap-highlight-selected.coffee

Lines changed: 0 additions & 68 deletions
This file was deleted.

lib/minimap-highlight-selected.js

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
const { CompositeDisposable } = require('atom')
2+
3+
module.exports = {
4+
activate () {
5+
this.subscriptions = new CompositeDisposable()
6+
7+
require('atom-package-deps').install('minimap-highlight-selected')
8+
},
9+
10+
consumeMinimapServiceV1 (minimap) {
11+
this.minimap = minimap
12+
this.minimap.registerPlugin('highlight-selected', this)
13+
},
14+
15+
consumeHighlightSelectedServiceV2 (highlightSelected) {
16+
this.highlightSelected = highlightSelected
17+
if (this.minimap && this.active) { this.init() }
18+
},
19+
20+
deactivate () {
21+
this.deactivatePlugin()
22+
this.minimapPackage = null
23+
this.highlightSelectedPackage = null
24+
this.highlightSelected = null
25+
this.minimap = null
26+
},
27+
28+
isActive () {
29+
return this.active
30+
},
31+
32+
activatePlugin () {
33+
if (this.active) { return }
34+
35+
this.subscriptions.add(this.minimap.onDidActivate(this.init.bind(this)))
36+
this.subscriptions.add(this.minimap.onDidDeactivate(this.dispose.bind(this)))
37+
38+
this.active = true
39+
40+
if (this.highlightSelected) {
41+
this.init()
42+
}
43+
},
44+
45+
init () {
46+
this.decorations = []
47+
this.highlightSelected.onDidAddMarkerForEditor(options => this.markerCreated(options))
48+
this.highlightSelected.onDidAddSelectedMarkerForEditor(options => this.markerCreated(options, true))
49+
this.highlightSelected.onDidRemoveAllMarkers(() => this.markersDestroyed())
50+
},
51+
52+
dispose () {
53+
if (this.decorations) {
54+
this.decorations.forEach(decoration => decoration.destroy())
55+
}
56+
this.decorations = null
57+
},
58+
59+
markerCreated (options, selected) {
60+
if (!selected) { selected = false }
61+
const minimap = this.minimap.minimapForEditor(options.editor)
62+
if (!minimap) { return }
63+
let className = 'highlight-selected'
64+
if (selected) { className += ' selected' }
65+
66+
const decoration = minimap.decorateMarker(options.marker,
67+
{ type: 'highlight', class: className })
68+
this.decorations.push(decoration)
69+
},
70+
71+
markersDestroyed () {
72+
if (this.decorations) {
73+
this.decorations.forEach(decoration => decoration.destroy())
74+
}
75+
this.decorations = []
76+
},
77+
78+
deactivatePlugin () {
79+
if (!this.active) { return }
80+
81+
this.active = false
82+
this.dispose()
83+
this.subscriptions.dispose()
84+
},
85+
}

spec/minimap-highlight-selected-spec.coffee

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const MinimapHighlightSelected = require('../lib/minimap-highlight-selected')
2+
3+
describe('MinimapHighlightSelected', () => {
4+
let workspace
5+
6+
beforeEach(async () => {
7+
workspace = atom.views.getView(atom.workspace)
8+
jasmine.attachToDOM(workspace)
9+
10+
// Package activation will be deferred to the configured, activation hook, which is then triggered
11+
// Activate activation hook
12+
atom.packages.triggerDeferredActivationHooks()
13+
atom.packages.triggerActivationHook('core:loaded-shell-environment')
14+
await atom.packages.activatePackage('minimap')
15+
await atom.packages.activatePackage('highlight-selected')
16+
})
17+
18+
describe('when the package is activated', () => {
19+
beforeEach(async () => {
20+
await atom.packages.activatePackage('minimap-highlight-selected')
21+
})
22+
23+
it('should activate', () => {
24+
expect(MinimapHighlightSelected.isActive()).toBe(true)
25+
})
26+
})
27+
})

0 commit comments

Comments
 (0)