Skip to content

Commit 45825c1

Browse files
authored
Merge pull request #12 from atom-minimap/update
2 parents 4677664 + d1193bd commit 45825c1

17 files changed

+8177
-187
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 bookmarks
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

.travis.yml

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

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# minimap-bookmarks package [![Build Status](https://travis-ci.org/atom-minimap/minimap-bookmarks.svg?branch=master)](https://travis-ci.org/atom-minimap/minimap-bookmarks)
1+
# minimap-bookmarks package
2+
3+
[![Build Status](https://github.com/atom-minimap/minimap-bookmarks/workflows/CI/badge.svg)](https://github.com/atom-minimap/minimap-bookmarks/actions)
24

35
Displays Atom bookmarks in the minimap.
46

lib/minimap-bookmarks-binding.coffee

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

lib/minimap-bookmarks-binding.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
const { CompositeDisposable } = require('atom')
2+
3+
class MinimapBookmarksBinding {
4+
constructor (minimap, bookmarks) {
5+
this.minimap = minimap
6+
this.bookmarks = bookmarks
7+
if ((this.minimap == null) || (this.bookmarks == null)) { return }
8+
9+
this.subscriptions = new CompositeDisposable()
10+
this.editor = this.minimap.getTextEditor()
11+
this.decorationsByMarkerId = {}
12+
this.decorationSubscriptionsByMarkerId = {}
13+
14+
// We need to wait until the bookmarks package had created its marker
15+
// layer before retrieving its id from the state.
16+
requestAnimationFrame(() => {
17+
// Also, targeting private properties on atom.packages is very brittle.
18+
// DO NOT DO THAT!
19+
//
20+
// If we really have to get the marker layer id from the
21+
// state (which can already break easily) it's better to get it from the
22+
// package `serialize` method since it's an API that is public and is
23+
// unlikely to change in a near future.
24+
const bookmarks = this.bookmarks.serialize()[this.editor.id]
25+
if (!bookmarks) { return }
26+
27+
const markerLayer = this.editor.getMarkerLayer(bookmarks.markerLayerId)
28+
29+
if (!markerLayer) { return }
30+
31+
this.subscriptions.add(markerLayer.onDidCreateMarker(marker => {
32+
this.handleMarker(marker)
33+
}))
34+
35+
markerLayer.findMarkers().forEach(marker => this.handleMarker(marker))
36+
})
37+
}
38+
39+
handleMarker (marker) {
40+
const { id } = marker
41+
const decoration = this.minimap.decorateMarker(marker, { type: 'line', class: 'bookmark', plugin: 'bookmarks' })
42+
this.decorationsByMarkerId[id] = decoration
43+
this.decorationSubscriptionsByMarkerId[id] = decoration.onDidDestroy(() => {
44+
this.decorationSubscriptionsByMarkerId[id].dispose()
45+
46+
delete this.decorationsByMarkerId[id]
47+
delete this.decorationSubscriptionsByMarkerId[id]
48+
})
49+
}
50+
51+
destroy () {
52+
for (const id in this.decorationsByMarkerId) {
53+
const decoration = this.decorationsByMarkerId[id]
54+
this.decorationSubscriptionsByMarkerId[id].dispose()
55+
decoration.destroy()
56+
57+
delete this.decorationsByMarkerId[id]
58+
delete this.decorationSubscriptionsByMarkerId[id]
59+
}
60+
61+
this.subscriptions.dispose()
62+
}
63+
}
64+
65+
module.exports = MinimapBookmarksBinding

lib/minimap-bookmarks.coffee

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

lib/minimap-bookmarks.js

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* decaffeinate suggestions:
3+
* DS102: Remove unnecessary code created because of implicit returns
4+
* DS201: Simplify complex destructure assignments
5+
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
6+
*/
7+
const { CompositeDisposable } = require('atom')
8+
let MinimapBookmarksBinding
9+
10+
module.exports = {
11+
isActive () {
12+
return this.active
13+
},
14+
15+
activate () {
16+
this.active = false
17+
this.subscriptions = new CompositeDisposable()
18+
this.bindings = {}
19+
require('atom-package-deps').install('minimap-git-diff')
20+
},
21+
22+
consumeMinimapServiceV1 (minimap) {
23+
this.minimap = minimap
24+
this.minimap.registerPlugin('bookmarks', this)
25+
},
26+
27+
deactivate () {
28+
if (this.minimap) {
29+
this.minimap.unregisterPlugin('bookmarks')
30+
}
31+
this.minimap = null
32+
},
33+
34+
activatePlugin () {
35+
if (this.active) {
36+
return
37+
}
38+
39+
const bookmarksPkg = atom.packages.getLoadedPackage('bookmarks')
40+
if (!bookmarksPkg) {
41+
return
42+
}
43+
const bookmarks = bookmarksPkg.mainModule
44+
this.active = true
45+
46+
this.minimapsSubscription = this.minimap.observeMinimaps(minimap => {
47+
if (!MinimapBookmarksBinding) {
48+
MinimapBookmarksBinding = require('./minimap-bookmarks-binding')
49+
}
50+
51+
const binding = new MinimapBookmarksBinding(minimap, bookmarks)
52+
this.bindings[minimap.id] = binding
53+
54+
const subscription = minimap.onDidDestroy(() => {
55+
binding.destroy()
56+
this.subscriptions.remove(subscription)
57+
subscription.dispose()
58+
delete this.bindings[minimap.id]
59+
})
60+
this.subscriptions.add(subscription)
61+
})
62+
},
63+
64+
deactivatePlugin () {
65+
if (!this.active) { return }
66+
67+
for (const id in this.bindings) { const binding = this.bindings[id]; binding.destroy() }
68+
this.bindings = {}
69+
this.active = false
70+
this.minimapsSubscription.dispose()
71+
this.subscriptions.dispose()
72+
},
73+
}

0 commit comments

Comments
 (0)