Skip to content

Commit 1b58f8f

Browse files
authored
Merge pull request #50 from atom-minimap/update
2 parents 8f7db25 + c349d21 commit 1b58f8f

12 files changed

+8081
-91
lines changed

.eslintrc.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
module.exports = {
2+
env: {
3+
es6: true,
4+
browser: true,
5+
node: true,
6+
jasmine: true,
7+
atomtest: true,
8+
},
9+
extends: [
10+
'standard',
11+
],
12+
globals: {
13+
atom: 'readonly',
14+
},
15+
parserOptions: {
16+
ecmaVersion: 2018,
17+
},
18+
rules: {
19+
'no-warning-comments': 'warn',
20+
'comma-dangle': ['error', 'always-multiline'],
21+
indent: ['error', 'tab', { SwitchCase: 1 }],
22+
'no-tabs': ['error', { allowIndentationTabs: true }],
23+
'no-restricted-globals': [
24+
'error',
25+
{
26+
name: 'fit',
27+
message: 'Do not commit focused tests.',
28+
},
29+
{
30+
name: 'fdescribe',
31+
message: 'Do not commit focused tests.',
32+
},
33+
],
34+
'no-sync': 'error',
35+
},
36+
}

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
- package-ecosystem: "npm"
8+
versioning-strategy: "increase"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"

.github/workflows/CI.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: "CI"
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- master
7+
8+
env:
9+
CI: true
10+
11+
jobs:
12+
Test:
13+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, macos-latest, windows-latest]
17+
channel: [stable, beta]
18+
fail-fast: false
19+
runs-on: ${{ matrix.os }}
20+
steps:
21+
- uses: actions/checkout@v2
22+
- uses: UziTech/action-setup-atom@v1
23+
with:
24+
channel: ${{ matrix.channel }}
25+
- name: Atom version
26+
run: atom -v
27+
- name: APM version
28+
run: apm -v
29+
- name: Install package dependencies
30+
run: apm i minimap highlight-selected
31+
- name: Install dependencies
32+
run: apm ci
33+
- name: Run tests 👩🏾‍💻
34+
run: atom --test spec
35+
36+
Lint:
37+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v2
41+
- uses: actions/[email protected]
42+
with:
43+
node-version: '*'
44+
- name: NPM install
45+
run: npm ci
46+
- name: Lint ✨
47+
run: npm run lint
48+
49+
Release:
50+
needs: [Test, Lint]
51+
if: |
52+
github.ref == 'refs/heads/master' &&
53+
github.event.repository.fork == false
54+
runs-on: ubuntu-latest
55+
steps:
56+
- uses: actions/checkout@v2
57+
- uses: UziTech/action-setup-atom@v1
58+
- uses: actions/[email protected]
59+
with:
60+
node-version: '*'
61+
- name: NPM install
62+
run: npm ci
63+
- name: Release 🎉
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
ATOM_ACCESS_TOKEN: ${{ secrets.ATOM_ACCESS_TOKEN }}
67+
run: npx semantic-release
68+
69+
Skip:
70+
if: contains(github.event.head_commit.message, '[skip ci]')
71+
runs-on: ubuntu-latest
72+
steps:
73+
- name: Skip CI 🚫
74+
run: echo skip ci

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# minimap-highlight-selected package
22

3+
[![Build Status](https://github.com/atom-minimap/minimap-highlight-selected/workflows/CI/badge.svg)](https://github.com/atom-minimap/minimap-highlight-selected/actions)
4+
35
A minimap binding for the [highlight-selected package](https://github.com/richrace/highlight-selected).
46

57
![Screenshot](https://github.com/atom-minimap/minimap-highlight-selected/blob/master/screenshot.png?raw=true)

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+
}

0 commit comments

Comments
 (0)