├── .eslintrc.js ├── .github ├── dependabot.yml └── workflows │ ├── Automerge.yml │ └── CI.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── lib ├── minimap-selection-view.js └── minimap-selection.js ├── package-lock.json ├── package.json ├── release.config.js ├── screenshot.gif ├── spec ├── fixtures │ └── sample.js ├── minimap-selection-spec.js └── runner.js └── styles └── minimap-selection.less /.eslintrc.js: -------------------------------------------------------------------------------- 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 | } 37 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 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" 12 | -------------------------------------------------------------------------------- /.github/workflows/Automerge.yml: -------------------------------------------------------------------------------- 1 | name: "Automerge" 2 | on: 3 | workflow_run: 4 | workflows: 5 | - CI 6 | types: 7 | - completed 8 | 9 | jobs: 10 | Automerge: 11 | runs-on: ubuntu-latest 12 | if: | 13 | github.event.workflow_run.event == 'pull_request' && 14 | github.event.workflow_run.conclusion == 'success' 15 | steps: 16 | - name: 'Merge PR' 17 | uses: actions/github-script@v6 18 | with: 19 | github-token: ${{ secrets.GITHUB_TOKEN }} 20 | script: | 21 | const pr = await github.rest.pulls.get({ 22 | owner: context.repo.owner, 23 | repo: context.repo.repo, 24 | pull_number: context.payload.workflow_run.pull_requests[0].number, 25 | }); 26 | if (!pr.data.title.startsWith('chore(deps-dev):')) { 27 | console.log('Not Merged 🚫'); 28 | console.log(`Title '${pr.data.title}' does not start with 'chore(deps-dev):'`); 29 | } else if (pr.data.user.login !== 'dependabot[bot]') { 30 | console.log('Not Merged 🚫'); 31 | console.log(`User '${pr.data.user.login}' does not equal 'dependabot[bot]'`); 32 | } else { 33 | await github.rest.pulls.merge({ 34 | owner: context.repo.owner, 35 | repo: context.repo.repo, 36 | pull_number: context.payload.workflow_run.pull_requests[0].number, 37 | }); 38 | console.log('Merged 🎉'); 39 | } 40 | -------------------------------------------------------------------------------- /.github/workflows/CI.yml: -------------------------------------------------------------------------------- 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@v3 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 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@v3 41 | - uses: actions/setup-node@v3 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@v3 57 | - uses: UziTech/action-setup-atom@v1 58 | - uses: actions/setup-node@v3 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 75 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | node_modules 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [4.5.5](https://github.com/atom-minimap/minimap-selection/compare/v4.5.4...v4.5.5) (2021-07-27) 2 | 3 | 4 | ### Bug Fixes 5 | 6 | * **deps:** bump atom-package-deps from 7.2.3 to 8.0.0 ([#72](https://github.com/atom-minimap/minimap-selection/issues/72)) ([d8cc341](https://github.com/atom-minimap/minimap-selection/commit/d8cc341d597917408ffc4eedbd1888a5d01cdd6f)) 7 | 8 | ## [4.5.4](https://github.com/atom-minimap/minimap-selection/compare/v4.5.3...v4.5.4) (2021-01-19) 9 | 10 | 11 | ### Bug Fixes 12 | 13 | * **deps:** bump atom-package-deps from 7.0.3 to 7.1.0 ([#20](https://github.com/atom-minimap/minimap-selection/issues/20)) ([6bcc76c](https://github.com/atom-minimap/minimap-selection/commit/6bcc76cd00d7228d93866b9f1d7ecfcff1a23743)) 14 | 15 | ## [4.5.3](https://github.com/atom-minimap/minimap-selection/compare/v4.5.2...v4.5.3) (2020-12-14) 16 | 17 | 18 | ### Bug Fixes 19 | 20 | * **deps:** bump atom-package-deps from 7.0.2 to 7.0.3 ([#14](https://github.com/atom-minimap/minimap-selection/issues/14)) ([3573f46](https://github.com/atom-minimap/minimap-selection/commit/3573f46610d0ae48e868610a9f1cca8a3774d315)) 21 | 22 | ## [4.5.2](https://github.com/atom-minimap/minimap-selection/compare/v4.5.1...v4.5.2) (2020-12-10) 23 | 24 | 25 | ### Bug Fixes 26 | 27 | * Optimizations ([#11](https://github.com/atom-minimap/minimap-selection/issues/11)) ([5378952](https://github.com/atom-minimap/minimap-selection/commit/5378952dc3bb1bf6a7c1d15e47f00f114f607223)) 28 | 29 | ## [4.5.1](https://github.com/atom-minimap/minimap-selection/compare/v4.5.0...v4.5.1) (2020-11-28) 30 | 31 | 32 | ### Bug Fixes 33 | 34 | * add minimap as dependency ([efa92c2](https://github.com/atom-minimap/minimap-selection/commit/efa92c235479a1c5e5e57dfb363e41465d2c100c)) 35 | * decaffeinate ([8d74802](https://github.com/atom-minimap/minimap-selection/commit/8d7480246f3f037af47d8da2ed75809bb1384a8b)) 36 | 37 | 38 | # v4.5.0 (2017-08-09) 39 | 40 | ## :sparkles: Features 41 | 42 | - Add a new setting to allow to render an outline around selections ([070f633b](https://github.com/atom-minimap/minimap-selection/commit/070f633b52b2b4f8518d5108baca05aa0e4a0859)) 43 | 44 | 45 | # v4.4.0 (2016-03-07) 46 | 47 | ## :sparkles: Features 48 | 49 | - Add plugin origin to created decorations ([645f4130](https://github.com/atom-minimap/minimap-selection/commit/645f41309abf975345cff20e3d4c9e7212e783af)) 50 | 51 | 52 | # v4.3.1 (2015-10-02) 53 | 54 | ## :bug: Bug Fixes 55 | 56 | - Fix potential infinite loop when an editor has no selection ([410e46f0](https://github.com/atom-minimap/minimap-selection/commit/410e46f019909397abf594bcebb3b27c12d6643f), [#6](https://githu 57 | 58 | 59 | # v4.3.0 (2015-06-29) 60 | 61 | ## :sparkles: Features 62 | 63 | - Implement highlighting lines with cursors ([bbab9ca0](https://github.com/atom-minimap/minimap-selection/commit/bbab9ca036757efbdf018349666022ba7241c1d4), [#5](https://github.com/atom-minimap/minimap-selection/issues/5)) 64 | 65 | ## :racehorse: Performances 66 | 67 | - Doesn't recreate decorations when selection ranges changes ([b9df94f8](https://github.com/atom-minimap/minimap-selection/commit/b9df94f8716de1c9133f8c80160d807629941a1d)) 68 | 69 | 70 | # v4.2.0 (2015-03-01) 71 | 72 | ## :sparkles: Features 73 | 74 | - Implement minimap service consumer for plugin registration ([84a2d37f](https://github.com/atom-minimap/minimap-selection/commit/84a2d37fef5edeabf88867bc90004fc348d6afa3)) 75 | 76 | 77 | # v4.1.0 (2015-02-20) 78 | 79 | ## :truck: Repository Migration 80 | 81 | - Migrate package repository to atom-minimap organization ([f7b01e01](https://github.com/atom-minimap/minimap-selection/commit/f7b01e0119d2fcc8b1da8951d4c7142eb31379f6)) 82 | 83 | 84 | # v4.0.1 (2015-02-10) 85 | 86 | ## :arrow_up: Dependencies Update 87 | 88 | - Update atom-space-pen-views to version 2.x ([d4aabbf4](https://github.com/atom-minimap/minimap-selection/commit/d4aabbf4819d3e3c4d7f98987a5dc9c13b229931)) 89 | - Update event-kit to version 1.x ([5087e006](https://github.com/atom-minimap/minimap-selection/commit/5087e006d6641b4481638a2c390f58c7cfac7efc)) 90 | 91 | 92 | # v4.0.0 (2015-02-10) 93 | 94 | ## :sparkles: Features 95 | 96 | - Add TravisCI setup ([3b9b6799](https://github.com/atom-minimap/minimap-selection/commit/3b9b679993c7541e05f06e642a197a8b68a9d493)) 97 | 98 | ## :bug: Bug Fixes 99 | 100 | - Fix errors raised when destroying the minimap ([c65692b5](https://github.com/atom-minimap/minimap-selection/commit/c65692b52e48b44585dd15575dbefd0e1420a6fb), [#4](https://github.com/atom-minimap/minimap-selection/issues/4)) 101 | 102 | 103 | # v3.1.1 (2015-01-08) 104 | 105 | ## :bug: Bug Fixes 106 | 107 | - Remove call to deprecated method ([3601f069](https://github.com/atom-minimap/minimap-selection/commit/3601f069b22a4cc80a2ea6aa1fe42e32c0fbf4bc)) 108 | 109 | 110 | # v3.1.0 (2015-01-05) 111 | 112 | ## :sparkles: Features 113 | 114 | - Implement support for both minimap v3 and v4 API ([096c17e3](https://github.com/atom-minimap/minimap-selection/commit/096c17e3a7af1f9cc7d3ab6746b64519ea7ae93e)) 115 | 116 | 117 | # 3.0.1 (2014-12-05) 118 | 119 | ## :bug: Bug Fixes 120 | 121 | - Fix use of deprecated minimap API ([f477b519](https://github.com/atom-minimap/minimap-selection/commit/f477b519870afbeea18624024ef9cf91c448dc96)) 122 | - Fix removal of inexistant decoration ([58559b81](https://github.com/atom-minimap/minimap-selection/commit/58559b818c05b4c0998f8223f3a251feea5c7393)) 123 | - Fix error raised when expanding the number of cursors ([c3d7b679](https://github.com/atom-minimap/minimap-selection/commit/c3d7b6797132dbf0219eadff2f5382b11e9dfceb)) 124 | - Fix broken plugin with latest minimap changes ([413f3a30](https://github.com/atom-minimap/minimap-selection/commit/413f3a306ac732be4998c400432ae0cea45e8bbe)) 125 | 126 | 127 | # v3.0.0 (2014-09-19) 128 | 129 | ## :sparkles: Features 130 | 131 | - Add version test for minimap v3 ([dfd89398](https://github.com/atom-minimap/minimap-selection/commit/dfd893984152e389b87ec154da01e64af2b55e37)) 132 | - Add a minimap class to the decoration scope ([050b072b](https://github.com/atom-minimap/minimap-selection/commit/050b072bb8e16925341fa97425dc10e288d25e8e)) 133 |
It’ll allow to have a specific style for the minimap selection 134 | - Implement support for the new minimap decoration API ([58d084b8](https://github.com/atom-minimap/minimap-selection/commit/58d084b8704780fcf63652ef41f13fcb29981ae0)) 135 | 136 | 137 | # 0.1.0 (2014-08-17) 138 | 139 | ## :sparkles: Features 140 | 141 | - Display buffer's selections on the minimap 142 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 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-selection package 2 | 3 | [![Build Status](https://github.com/atom-minimap/minimap-selection/workflows/CI/badge.svg)](https://github.com/atom-minimap/minimap-selection/actions) 4 | 5 | Display the buffer's selections on the minimap 6 | 7 | ![Screenshot](https://github.com/atom-minimap/minimap-selection/blob/master/screenshot.gif?raw=true) 8 | 9 | ## Settings 10 | 11 | ### Highlight Cursors Lines 12 | 13 | When enabled, lines that holds a cursors will be highlighted in the minimap. 14 | 15 | ### Customization 16 | 17 | The selection color can be customized using the following CSS rule in your user stylesheet: 18 | 19 | ```css 20 | .minimap-selection .region { 21 | background: green; 22 | } 23 | ``` 24 | 25 | When the `Highlight Cursors Lines` setting is enabled the line's highlight color can be customized using the following CSS rule in your user stylesheet: 26 | 27 | ```css 28 | .minimap-selection .cursor-line { 29 | background: blue; 30 | } 31 | ``` 32 | 33 | When the `Outline Selection` setting is enabled, the outline color can be customized using the following CSS rule: 34 | 35 | ```css 36 | .minimap-selection .region-outline { 37 | background: green; 38 | } 39 | ``` 40 | -------------------------------------------------------------------------------- /lib/minimap-selection-view.js: -------------------------------------------------------------------------------- 1 | const { CompositeDisposable } = require('atom') 2 | 3 | class MinimapSelectionView { 4 | constructor (minimap) { 5 | this.decorations = [] 6 | this.handleSelection = this.handleSelection.bind(this) 7 | this.minimap = minimap 8 | const editor = this.minimap.getTextEditor() 9 | 10 | this.subscriptions = new CompositeDisposable( 11 | editor.onDidAddCursor(this.handleSelection), 12 | editor.onDidChangeCursorPosition(this.handleSelection), 13 | editor.onDidRemoveCursor(this.handleSelection), 14 | atom.config.observe('minimap-selection.outlineSelection', this.handleSelection), 15 | ) 16 | this.handleSelection() 17 | } 18 | 19 | destroy () { 20 | this.removeDecorations() 21 | this.subscriptions.dispose() 22 | this.minimap = null 23 | } 24 | 25 | handleSelection () { 26 | this.removeDecorations() 27 | 28 | const textEditor = this.minimap.getTextEditor() 29 | if (!textEditor.selections || textEditor.selections.length === 0) { return } 30 | 31 | for (const selection of textEditor.getSelections()) { 32 | let decoration 33 | if (!selection.isEmpty()) { 34 | decoration = this.minimap.decorateMarker(selection.marker, { type: 'highlight-under', scope: '.minimap .minimap-selection .region', plugin: 'selection' }) 35 | if (decoration) { 36 | this.decorations.push(decoration) 37 | } 38 | 39 | if (atom.config.get('minimap-selection.outlineSelection')) { 40 | decoration = this.minimap.decorateMarker(selection.marker, { type: 'highlight-outline', scope: '.minimap .minimap-selection .region-outline', plugin: 'selection' }) 41 | if (decoration) { 42 | this.decorations.push(decoration) 43 | } 44 | } 45 | } else if (atom.config.get('minimap-selection.highlightCursorsLines')) { 46 | decoration = this.minimap.decorateMarker(selection.marker, { type: 'line', scope: '.minimap .minimap-selection .cursor-line', plugin: 'selection' }) 47 | if (decoration) { 48 | this.decorations.push(decoration) 49 | } 50 | } 51 | } 52 | } 53 | 54 | removeDecorations () { 55 | if (this.decorations.length === 0) { return } 56 | for (const decoration of this.decorations) { 57 | if (decoration) { 58 | decoration.destroy() 59 | } 60 | } 61 | this.decorations = [] 62 | } 63 | } 64 | 65 | module.exports = MinimapSelectionView 66 | -------------------------------------------------------------------------------- /lib/minimap-selection.js: -------------------------------------------------------------------------------- 1 | const MinimapSelectionView = require('./minimap-selection-view') 2 | 3 | module.exports = { 4 | config: { 5 | highlightCursorsLines: { 6 | type: 'boolean', 7 | default: false, 8 | description: 'When true, the lines with cursors are highlighted in the minimap.', 9 | }, 10 | outlineSelection: { 11 | type: 'boolean', 12 | default: false, 13 | description: 'When true, the selections will also be rendered with outline decorations.', 14 | }, 15 | }, 16 | 17 | activate () { 18 | this.active = false 19 | this.views = new Map() 20 | require('atom-package-deps').install('minimap-selection') 21 | }, 22 | 23 | consumeMinimapServiceV1 (minimap) { 24 | this.minimap = minimap 25 | this.minimap.registerPlugin('selection', this) 26 | }, 27 | 28 | deactivate () { 29 | this.minimap.unregisterPlugin('selection') 30 | this.minimap = null 31 | }, 32 | 33 | isActive () { 34 | return this.active 35 | }, 36 | 37 | activatePlugin () { 38 | if (this.active) { return } 39 | this.active = true 40 | 41 | this.subscription = this.minimap.observeMinimaps(o => { 42 | const minimap = o.view ? o.view : o 43 | const selectionView = new MinimapSelectionView(minimap) 44 | 45 | this.views.set(minimap.id, selectionView) 46 | 47 | const disposable = minimap.onDidDestroy(() => { 48 | selectionView.destroy() 49 | this.views.delete(minimap.id) 50 | disposable.dispose() 51 | }) 52 | }) 53 | }, 54 | 55 | deactivatePlugin () { 56 | if (!this.active) { return } 57 | const views = this.views.values() 58 | for (const view of views) { view.destroy() } 59 | this.active = false 60 | this.views.clear() 61 | this.subscription.dispose() 62 | }, 63 | } 64 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minimap-selection", 3 | "main": "./lib/minimap-selection", 4 | "version": "4.5.5", 5 | "description": "Display the buffer's selections on the minimap", 6 | "repository": "https://github.com/atom-minimap/minimap-selection", 7 | "license": "MIT", 8 | "engines": { 9 | "atom": ">=1.20.0" 10 | }, 11 | "scripts": { 12 | "test": "atom --test spec", 13 | "lint": "eslint ." 14 | }, 15 | "atomTestRunner": "./spec/runner.js", 16 | "package-deps": [ 17 | { 18 | "name": "minimap" 19 | } 20 | ], 21 | "dependencies": { 22 | "atom-package-deps": "^8.0.0" 23 | }, 24 | "devDependencies": { 25 | "@semantic-release/apm-config": "^8.0.0", 26 | "atom-jasmine3-test-runner": "^5.2.13", 27 | "eslint": "^7.32.0", 28 | "eslint-config-standard": "^16.0.3", 29 | "eslint-plugin-import": "^2.26.0", 30 | "eslint-plugin-node": "^11.1.0", 31 | "eslint-plugin-promise": "^5.2.0", 32 | "eslint-plugin-react": "^7.31.1", 33 | "semantic-release": "^19.0.5" 34 | }, 35 | "consumedServices": { 36 | "minimap": { 37 | "versions": { 38 | "1.0.0": "consumeMinimapServiceV1" 39 | } 40 | } 41 | }, 42 | "activationHooks": [ 43 | "core:loaded-shell-environment" 44 | ] 45 | } 46 | -------------------------------------------------------------------------------- /release.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: '@semantic-release/apm-config', 3 | } 4 | -------------------------------------------------------------------------------- /screenshot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atom-minimap/minimap-selection/0a49c5784f6f8e680676e688771ad65f0e7208ac/screenshot.gif -------------------------------------------------------------------------------- /spec/fixtures/sample.js: -------------------------------------------------------------------------------- 1 | /** @babel */ 2 | 3 | export const a = 1 4 | -------------------------------------------------------------------------------- /spec/minimap-selection-spec.js: -------------------------------------------------------------------------------- 1 | // const MinimapSelection = require('../lib/minimap-selection') 2 | 3 | describe('MinimapSelection', () => { 4 | let workspace, editor, minimap, decorationManagement 5 | 6 | beforeEach(async () => { 7 | workspace = atom.views.getView(atom.workspace) 8 | jasmine.attachToDOM(workspace) 9 | 10 | editor = await atom.workspace.open('sample.js') 11 | 12 | // Package activation will be deferred to the configured, activation hook, which is then triggered 13 | // Activate activation hook 14 | atom.packages.triggerDeferredActivationHooks() 15 | atom.packages.triggerActivationHook('core:loaded-shell-environment') 16 | 17 | const minimapPkg = await atom.packages.activatePackage('minimap') 18 | minimap = minimapPkg.mainModule.minimapForEditor(editor) 19 | 20 | await atom.packages.activatePackage('minimap-selection') 21 | 22 | decorationManagement = minimap.getDecorationManagement() 23 | spyOn(decorationManagement, 'decorateMarker').and.callThrough() 24 | spyOn(decorationManagement, 'removeDecoration').and.callThrough() 25 | }) 26 | 27 | describe('when a selection is made in the text editor', () => { 28 | it('adds a decoration for the selection in the minimap', () => { 29 | editor.setSelectedBufferRange([[1, 0], [2, 10]]) 30 | console.log(minimap.getDecorations()) 31 | expect(decorationManagement.decorateMarker).toHaveBeenCalled() 32 | }) 33 | 34 | it('removes the previously added decoration', () => { 35 | editor.setSelectedBufferRange([[1, 0], [2, 10]]) 36 | editor.setSelectedBufferRange([[0, 0], [0, 0]]) 37 | expect(decorationManagement.removeDecoration).toHaveBeenCalled() 38 | }) 39 | }) 40 | }) 41 | -------------------------------------------------------------------------------- /spec/runner.js: -------------------------------------------------------------------------------- 1 | const { createRunner } = require('atom-jasmine3-test-runner') 2 | 3 | module.exports = createRunner({ 4 | specHelper: { 5 | attachToDom: true, 6 | ci: true, 7 | }, 8 | testPackages: ['minimap'], 9 | }) 10 | -------------------------------------------------------------------------------- /styles/minimap-selection.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 | 7 | @contain_all: layout size paint style; 8 | 9 | .minimap-selection .region { 10 | contain: @contain_all; 11 | background: @background-color-selected; 12 | } 13 | 14 | .minimap-selection .region-outline { 15 | contain: @contain_all; 16 | background: @text-color; 17 | } 18 | 19 | .minimap-selection .cursor-line { 20 | contain: @contain_all; 21 | background: @background-color-selected; 22 | } 23 | --------------------------------------------------------------------------------