├── .gitignore ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── demo.gif ├── lib ├── minimap-split-diff-binding.coffee └── minimap-split-diff.coffee ├── package.json ├── spec └── minimap-split-diff-spec.coffee └── styles └── minimap-split-diff.less /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.3.7 - 2017-03-17 2 | * Changed README to specify split-diff and minimap packages are needed - thanks kjmitch! 3 | 4 | ## 0.3.6 - 2017-02-20 5 | * Added information about style customization to README 6 | 7 | ## 0.3.5 - 2017-02-12 8 | * Rerelease changes made for v0.3.3 but scoped to Atom v1.14 and greater 9 | 10 | ## 0.3.4 - 2017-02-12 11 | * Fixed error in Atom v1.13 due to MarkerLayer bug (rollback changes) 12 | 13 | ## 0.3.3 - 2017-02-09 14 | * Changed to now use split-diff's service API to get marker layers 15 | 16 | ## 0.3.2 - 2016-10-11 17 | * Fixed colors to use syntax theme #4 - thanks noyouaretheman! 18 | 19 | ## 0.3.1 - 2016-06-07 20 | * Fixed Uncaught TypeError (introduced by Atom v1.9beta) #3 21 | 22 | ## 0.3.0 - 2015-11-03 23 | * Added ability to show next/prev diff 24 | 25 | ## 0.2.1 - 2015-11-03 26 | * Fixed issue #1 and issue #2 27 | 28 | ## 0.2.0 - 2015-10-07 29 | * Added ability to activate/deactivate plugin 30 | 31 | ## 0.1.0 - First Release 32 | * Every feature added 33 | * Every bug fixed 34 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Michael Upchurch 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # minimap-split-diff [![Installs!](https://img.shields.io/apm/dm/minimap-split-diff.svg?style=flat-square)](https://atom.io/packages/minimap-split-diff) [![Version!](https://img.shields.io/apm/v/minimap-split-diff.svg?style=flat-square)](https://atom.io/packages/minimap-split-diff) [![License](https://img.shields.io/apm/l/minimap-split-diff.svg?style=flat-square)](https://github.com/mupchrch/minimap-split-diff/blob/master/LICENSE.md) 2 | 3 | A plugin that adds [Split Diff's](https://github.com/mupchrch/split-diff) highlighting to the [Minimap](https://github.com/atom-minimap/minimap) view, making it easier to find differences throughout file versions in Atom. 4 | 5 | ![Minimap Split Diff plugin in action](https://github.com/mupchrch/minimap-split-diff/raw/master/demo.gif) 6 | 7 | ### Customization 8 | 9 | The highlighting for this package uses global UI variables defined in your syntax theme. The variables are `@syntax-color-added`, `@syntax-color-removed`, and `@syntax-color-modified`. Make sure your theme defines these, so it is compatible with this package! 10 | 11 | To override these colors in your `styles.less`, write selectors for `.minimap .added`, `.minimap .removed`, and/or `.minimap .selected`. For instance: 12 | 13 | ``` 14 | .minimap .added { 15 | background: blue !important; 16 | } 17 | ``` 18 | 19 | ### Notes 20 | 21 | Both the Split Diff and Minimap packages must also be installed and enabled in Atom for this package to work. 22 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mupchrch/minimap-split-diff/14b912f51647886e0ffc241bffb5a638f79ced52/demo.gif -------------------------------------------------------------------------------- /lib/minimap-split-diff-binding.coffee: -------------------------------------------------------------------------------- 1 | {CompositeDisposable} = require 'event-kit' 2 | 3 | module.exports = 4 | class MinimapSplitDiffBinding 5 | constructor: (@minimap) -> 6 | @editor = @minimap.getTextEditor() 7 | @splitDecorations = [] 8 | @subscriptions = new CompositeDisposable 9 | 10 | handleMarkerLayers: (markerLayers) -> 11 | if markerLayers? 12 | editor1 = markerLayers.editor1 13 | editor2 = markerLayers.editor2 14 | 15 | if @editor?.id == editor1.id 16 | # handle current markers 17 | @handleMarkerLayer(editor1.lineMarkerLayer, editor1.highlightType) 18 | @handleMarkerLayer(editor1.selectionMarkerLayer, 'selected') 19 | # then attach update listener for future markers 20 | editor1.lineMarkerLayer.onDidUpdate () => 21 | @handleMarkerLayer(editor1.lineMarkerLayer, editor1.highlightType) 22 | editor1.selectionMarkerLayer.onDidUpdate () => 23 | @handleMarkerLayer(editor1.selectionMarkerLayer, 'selected') 24 | else if @editor?.id == editor2.id 25 | # handle current markers 26 | @handleMarkerLayer(editor2.lineMarkerLayer, editor2.highlightType) 27 | @handleMarkerLayer(editor2.selectionMarkerLayer, 'selected') 28 | # then attach update listener for future markers 29 | editor2.lineMarkerLayer.onDidUpdate () => 30 | @handleMarkerLayer(editor2.lineMarkerLayer, editor2.highlightType) 31 | editor2.selectionMarkerLayer.onDidUpdate () => 32 | @handleMarkerLayer(editor2.selectionMarkerLayer, 'selected') 33 | 34 | destroy: -> 35 | @removeMarkers() 36 | @splitDecorations = null 37 | @subscriptions.dispose() 38 | @minimap = null 39 | @editor = null 40 | 41 | removeMarkers: -> 42 | if @splitDecorations 43 | for decoration in @splitDecorations 44 | decoration.destroy() 45 | 46 | handleMarkerLayer: (markerLayer, highlightType) -> 47 | markerLayer.getMarkers().forEach (marker) => 48 | @createDecoration(marker, highlightType) 49 | 50 | # highlight types include: added, removed, selected 51 | createDecoration: (marker, highlightType) -> 52 | minimapDecoration = @minimap.decorateMarker(marker, type: 'line', class: highlightType) 53 | @splitDecorations.push minimapDecoration 54 | -------------------------------------------------------------------------------- /lib/minimap-split-diff.coffee: -------------------------------------------------------------------------------- 1 | {CompositeDisposable} = require 'event-kit' 2 | 3 | module.exports = 4 | active: false 5 | markerLayers: null 6 | bindingsById: {} 7 | subscriptionsById: {} 8 | subscriptions: {} 9 | 10 | isActive: -> @active 11 | 12 | activate: (state) -> 13 | @subscriptions = new CompositeDisposable 14 | 15 | consumeSplitDiff: (splitDiffService) -> 16 | @waitForDiff(splitDiffService) 17 | 18 | consumeMinimapServiceV1: (@minimap) -> 19 | @minimap.registerPlugin 'split-diff', this 20 | 21 | deactivate: -> 22 | @minimap.unregisterPlugin 'split-diff' 23 | @minimap = null 24 | 25 | waitForDiff: (splitDiffService)-> 26 | splitDiffService.getMarkerLayers().then (@markerLayers) => 27 | for i of @bindingsById 28 | @bindingsById[i].handleMarkerLayers(@markerLayers) 29 | @markerLayers.editor1.lineMarkerLayer.onDidDestroy () => 30 | @markerLayers = null 31 | @waitForDiff(splitDiffService) 32 | 33 | activatePlugin: -> 34 | return if @active 35 | 36 | @active = true 37 | 38 | @subscriptions.add @minimap.observeMinimaps (minimap) => 39 | MinimapSplitDiffBinding = require './minimap-split-diff-binding' 40 | 41 | binding = new MinimapSplitDiffBinding(minimap) 42 | @bindingsById[minimap.id] = binding 43 | 44 | binding.handleMarkerLayers(@markerLayers) 45 | 46 | @subscriptionsById[minimap.id] = minimap.onDidDestroy => 47 | @subscriptionsById[minimap.id]?.dispose() 48 | @bindingsById[minimap.id]?.destroy() 49 | 50 | delete @bindingsById[minimap.id] 51 | delete @subscriptionsById[minimap.id] 52 | 53 | deactivatePlugin: -> 54 | return unless @active 55 | 56 | @active = false 57 | for i of @bindingsById 58 | @bindingsById[i].destroy() 59 | @subscriptions.dispose() 60 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minimap-split-diff", 3 | "main": "./lib/minimap-split-diff", 4 | "version": "0.3.7", 5 | "description": "A minimap plugin for the Split Diff package", 6 | "repository": "https://github.com/mupchrch/minimap-split-diff", 7 | "license": "MIT", 8 | "engines": { 9 | "atom": ">= 1.14.0 < 2.0.0" 10 | }, 11 | "consumedServices": { 12 | "split-diff": { 13 | "versions": { 14 | "1.0.0": "consumeSplitDiff" 15 | } 16 | }, 17 | "minimap": { 18 | "versions": { 19 | "1.0.0": "consumeMinimapServiceV1" 20 | } 21 | } 22 | }, 23 | "dependencies": { 24 | "event-kit": ">= 0.7.2" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /spec/minimap-split-diff-spec.coffee: -------------------------------------------------------------------------------- 1 | MinimapSplitDiff = require '../lib/minimap-split-diff' 2 | 3 | # Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs. 4 | # 5 | # To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit` 6 | # or `fdescribe`). Remove the `f` to unfocus the block. 7 | 8 | describe "MinimapSplitDiff", -> 9 | [workspaceElement, editor] = [] 10 | 11 | beforeEach -> 12 | workspaceElement = atom.views.getView(atom.workspace) 13 | jasmine.attachToDOM(workspaceElement) 14 | 15 | waitsForPromise -> 16 | atom.workspace.open('sample.js') 17 | 18 | runs -> 19 | editor = atom.workspace.getActiveTextEditor() 20 | editor.setText("This is the file content") 21 | 22 | waitsForPromise -> 23 | atom.packages.activatePackage('minimap') 24 | 25 | waitsForPromise -> 26 | atom.packages.activatePackage('minimap-split-diff') 27 | 28 | describe "with an open editor that have a minimap", -> 29 | it "lives", -> 30 | expect('life').toBe('easy') 31 | -------------------------------------------------------------------------------- /styles/minimap-split-diff.less: -------------------------------------------------------------------------------- 1 | // The ui-variables file is provided by base themes provided by Atom. 2 | // 3 | // See https://github.com/atom/atom-dark-ui/blob/master/stylesheets/ui-variables.less 4 | // for a full listing of what's available. 5 | @import "ui-variables"; 6 | @import "syntax-variables"; 7 | 8 | .minimap .added { 9 | background: @syntax-color-added; 10 | } 11 | 12 | .minimap .removed { 13 | background: @syntax-color-removed; 14 | } 15 | 16 | .minimap .selected { 17 | background: @syntax-color-modified; 18 | } 19 | --------------------------------------------------------------------------------