Skip to content

Commit

Permalink
fix: add minimap as dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech committed Nov 28, 2020
1 parent 38384ed commit dc98d64
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 30 deletions.
54 changes: 24 additions & 30 deletions lib/minimap-git-diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,35 @@ const { CompositeDisposable } = require('atom')

let MinimapGitDiffBinding = null

class MinimapGitDiff {
constructor () {
this.pluginActive = false
this.createBindings = this.createBindings.bind(this)
this.destroyBindings = this.destroyBindings.bind(this)
this.subscriptions = new CompositeDisposable()
}

get config () {
return {
useGutterDecoration: {
type: 'boolean',
default: false,
description: 'When enabled the git diffs will be displayed as thin vertical lines on the left side of the minimap.',
},
}
}

isActive () { return this.pluginActive }
module.exports = {
config: {
useGutterDecoration: {
type: 'boolean',
default: false,
description: 'When enabled the git diffs will be displayed as thin vertical lines on the left side of the minimap.',
},
},

isActive () {
return this.pluginActive
},

activate () {
this.pluginActive = false
this.subscriptions = new CompositeDisposable()
this.bindings = new WeakMap()
}
require('atom-package-deps').install('minimap-git-diff')
},

consumeMinimapServiceV1 (minimap) {
this.minimap = minimap
return this.minimap.registerPlugin('git-diff', this)
}
},

deactivate () {
this.destroyBindings()
this.minimap = null
}
},

activatePlugin () {
if (this.pluginActive) { return }
Expand All @@ -43,20 +39,20 @@ class MinimapGitDiff {
this.createBindings()
this.pluginActive = true

this.subscriptions.add(this.minimap.onDidActivate(this.createBindings))
this.subscriptions.add(this.minimap.onDidDeactivate(this.destroyBindings))
this.subscriptions.add(this.minimap.onDidActivate(this.createBindings.bind(this)))
this.subscriptions.add(this.minimap.onDidDeactivate(this.destroyBindings.bind(this)))
} catch (e) {
console.log(e)
}
}
},

deactivatePlugin () {
if (!this.pluginActive) { return }

this.pluginActive = false
this.subscriptions.dispose()
this.destroyBindings()
}
},

createBindings () {
if (!MinimapGitDiffBinding) { MinimapGitDiffBinding = require('./minimap-git-diff-binding') }
Expand All @@ -71,7 +67,7 @@ class MinimapGitDiff {
this.bindings.set(minimap, binding)
}),
)
}
},

destroyBindings () {
if (!this.minimap || !this.minimap.editorsMinimaps) { return }
Expand All @@ -82,7 +78,5 @@ class MinimapGitDiff {
}
this.bindings.delete(minimap)
})
}
},
}

module.exports = new MinimapGitDiff()
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
"lint": "eslint ."
},
"atomTestRunner": "./spec/runner.js",
"package-deps": [
{
"name": "minimap"
}
],
"dependencies": {
"atom-package-deps": "^7.0.2"
},
"devDependencies": {
"@semantic-release/apm-config": "^8.0.0",
"atom-jasmine3-test-runner": "^5.1.8",
Expand Down

0 comments on commit dc98d64

Please sign in to comment.