From 8266489296b09c53fb3e96ee4b0fb0160d1564cb Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 15 Jan 2021 01:10:04 -0600 Subject: [PATCH 1/4] feat: remove plugin order rendering config (z-index) --- lib/main.js | 13 ---------- lib/minimap-element.js | 4 --- lib/mixins/canvas-drawer.js | 7 +---- lib/plugin-management.js | 51 ++----------------------------------- 4 files changed, 3 insertions(+), 72 deletions(-) diff --git a/lib/main.js b/lib/main.js index 04cd17bd..7ccadaf2 100644 --- a/lib/main.js +++ b/lib/main.js @@ -253,17 +253,6 @@ export function onDidDeactivatePlugin (callback) { return emitter.on('did-deactivate-plugin', callback) } -/** - * Registers a callback to listen to the `did-change-plugin-order` event of - * the package. - * - * @param {function(event:Object):void} callback the callback function - * @return {Disposable} a disposable to stop listening to the event - */ -export function onDidChangePluginOrder (callback) { - return emitter.on('did-change-plugin-order', callback) -} - /** * Returns the `Minimap` class * @@ -388,7 +377,6 @@ const MinimapServiceV1 = { onDidRemovePlugin, onDidActivatePlugin, onDidDeactivatePlugin, - onDidChangePluginOrder, minimapClass, minimapForEditorElement, minimapForEditor, @@ -401,7 +389,6 @@ const MinimapServiceV1 = { deactivateAllPlugins: PluginManagement.deactivateAllPlugins, activatePlugin: PluginManagement.activatePlugin, deactivatePlugin: PluginManagement.deactivatePlugin, - getPluginsOrder: PluginManagement.getPluginsOrder } /** diff --git a/lib/minimap-element.js b/lib/minimap-element.js index 7171c872..3442e9e8 100644 --- a/lib/minimap-element.js +++ b/lib/minimap-element.js @@ -708,10 +708,6 @@ class MinimapElement { } this.requestUpdate() }), - - Main.onDidChangePluginOrder(() => { - this.requestForcedUpdate() - }) ) this.setStandAlone(this.minimap.isStandAlone()) diff --git a/lib/mixins/canvas-drawer.js b/lib/mixins/canvas-drawer.js index 15772a22..1ea17fe4 100644 --- a/lib/mixins/canvas-drawer.js +++ b/lib/mixins/canvas-drawer.js @@ -3,7 +3,6 @@ import { escapeRegExp } from '../deps/underscore-plus' import Mixin from 'mixto' -import * as Main from '../main' import { domStylesReader } from '../main' import CanvasLayer from '../canvas-layer' @@ -149,7 +148,7 @@ export default class CanvasDrawer extends Mixin { lineHeight, charWidth, charHeight, - orders: Main.getPluginsOrder() + orders: {} } const drawCustomDecorationLambda = (decoration, data, decorationColor) => drawCustomDecoration(decoration, data, decorationColor, editorElement) @@ -777,10 +776,6 @@ function drawDecorations (screenRow, decorations, renderData, types, editorEleme ) } - decorationsToRender.sort((a, b) => - (renderData.orders[a.properties.plugin] || 0) - (renderData.orders[b.properties.plugin] || 0) - ) - if (decorationsToRender != null ? decorationsToRender.length : undefined) { for (let i = 0, len = decorationsToRender.length; i < len; i++) { const decoration = decorationsToRender[i] diff --git a/lib/plugin-management.js b/lib/plugin-management.js index 77824bfb..8981f426 100644 --- a/lib/plugin-management.js +++ b/lib/plugin-management.js @@ -36,14 +36,6 @@ export const plugins = {} */ const pluginsSubscriptions = {} -/** - * A map that stores the display order for each plugin - * - * @type {Object} - * @access private - */ -const pluginsOrderMap = {} - /** * Registers a minimap `plugin` with the given `name`. * @@ -63,7 +55,7 @@ export function registerPlugin (name, plugin) { emitter.emit('did-add-plugin', event) if (atom.config.get('minimap.displayPluginsControls')) { - registerPluginControls(name, plugin) + registerPluginControls(name) } updatesPluginActivationState(name) @@ -192,9 +184,8 @@ export function deactivatePlugin (name, plugin) { * to toggle the plugin state. * @access private */ -function registerPluginControls (name, plugin) { +function registerPluginControls (name) { const settingsKey = `minimap.plugins.${name}` - const orderSettingsKey = `minimap.plugins.${name}DecorationsZIndex` const config = getConfigSchema() @@ -205,59 +196,21 @@ function registerPluginControls (name, plugin) { default: true } - config.plugins.properties[`${name}DecorationsZIndex`] = { - type: 'integer', - title: `${name} decorations order`, - description: `The relative order of the ${name} plugin's decorations in the layer into which they are drawn. Note that this order only apply inside a layer, so highlight-over decorations will always be displayed above line decorations as they are rendered in different layers.`, - default: 0 - } - if (atom.config.get(settingsKey) === undefined) { atom.config.set(settingsKey, true) } - if (atom.config.get(orderSettingsKey) === undefined) { - atom.config.set(orderSettingsKey, 0) - } - pluginsSubscriptions[name].add(atom.config.observe(settingsKey, () => { updatesPluginActivationState(name) })) - pluginsSubscriptions[name].add(atom.config.observe(orderSettingsKey, (order) => { - updatePluginsOrderMap(name) - const event = { name, plugin, order } - emitter.emit('did-change-plugin-order', event) - })) - pluginsSubscriptions[name].add(atom.commands.add('atom-workspace', { [`minimap:toggle-${name}`]: () => { togglePluginActivation(name) } })) - - updatePluginsOrderMap(name) -} - -/** - * Updates the display order in the map for the passed-in plugin name. - * - * @param {string} name the name of the plugin to update - * @access private - */ -function updatePluginsOrderMap (name) { - const orderSettingsKey = `minimap.plugins.${name}DecorationsZIndex` - - pluginsOrderMap[name] = atom.config.get(orderSettingsKey) } -/** - * Returns the plugins display order mapped by name. - * - * @return {Object} The plugins order by name - */ -export function getPluginsOrder () { return pluginsOrderMap } - /** * When the `minimap.displayPluginsControls` setting is toggled, * this function will unregister the commands and setting that From 0822710096246f013cfeaa0f7055fcd4395ad446 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 15 Jan 2021 02:16:31 -0600 Subject: [PATCH 2/4] test: remove z-index spec --- spec/minimap-element-spec.js | 4 +--- spec/minimap-main-spec.js | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/spec/minimap-element-spec.js b/spec/minimap-element-spec.js index bde75bef..f31ab36e 100644 --- a/spec/minimap-element-spec.js +++ b/spec/minimap-element-spec.js @@ -350,8 +350,6 @@ describe('MinimapElement', () => { expect(calls).toEqual(['bar', 'foo']) - atom.config.set('minimap.plugins.fooDecorationsZIndex', -1) - calls.length = 0 }) @@ -362,7 +360,7 @@ describe('MinimapElement', () => { runs(() => { nextAnimationFrame() - expect(calls).toEqual(['foo', 'bar']) + expect(calls).toEqual(['bar', 'foo']) Main.unregisterPlugin('foo') Main.unregisterPlugin('bar') diff --git a/spec/minimap-main-spec.js b/spec/minimap-main-spec.js index c886c14e..dbc3cc23 100644 --- a/spec/minimap-main-spec.js +++ b/spec/minimap-main-spec.js @@ -178,12 +178,10 @@ describe('Minimap package', () => { it('creates a default config for the plugin', () => { expect(minimapPackage.getConfigSchema().plugins.properties.dummy).toBeDefined() - expect(minimapPackage.getConfigSchema().plugins.properties.dummyDecorationsZIndex).toBeDefined() }) it('sets the corresponding config', () => { expect(atom.config.get('minimap.plugins.dummy')).toBeTruthy() - expect(atom.config.get('minimap.plugins.dummyDecorationsZIndex')).toEqual(0) }) describe('triggering the corresponding plugin command', () => { From ae68f622ba495fec59186b40eee72530cf6882ce Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 15 Jan 2021 02:17:20 -0600 Subject: [PATCH 3/4] chore: remove z-index from readme --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index f982437c..f5fd0a76 100644 --- a/README.md +++ b/README.md @@ -136,8 +136,6 @@ When several plugins create decorations for the same layer, the general rule is - On the foreground layer, the `highlight-over` decorations are rendered before the `highlight-outine` decorations. - When two plugins adds the same type of decorations at the same place, the decorations are rendered in the order they have been created. -But fortunately, it's possible to reorder decorations on their specific layer using these settings. These settings works as a `z-index` in CSS, the higher the value, the higher the decorations will be in the render stack, for instance, a plugin's decorations with an order value of `1` will appear above decorations from a plugin with an order value of `0`. - #### Smooth Scrolling Whether to offset the minimap canvas when scrolling to keep the scroll smooth. When `true` the minimap canvas will be offseted, resulting in a smoother scroll, but with the side-effect of a blurry minimap when the canvas is placed between pixels. When `false` the canvas will always stay at the same position, and will never look blurry, but the scroll will appear more jagged. `(default=true)` From a2f4c3afb5fd1accb6a8966b78653c65146a747b Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 15 Jan 2021 02:17:58 -0600 Subject: [PATCH 4/4] chore: lint --- lib/main.js | 2 +- lib/minimap-element.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 7ccadaf2..e59150c9 100644 --- a/lib/main.js +++ b/lib/main.js @@ -388,7 +388,7 @@ const MinimapServiceV1 = { togglePluginActivation: PluginManagement.togglePluginActivation, deactivateAllPlugins: PluginManagement.deactivateAllPlugins, activatePlugin: PluginManagement.activatePlugin, - deactivatePlugin: PluginManagement.deactivatePlugin, + deactivatePlugin: PluginManagement.deactivatePlugin } /** diff --git a/lib/minimap-element.js b/lib/minimap-element.js index 3442e9e8..0b71773a 100644 --- a/lib/minimap-element.js +++ b/lib/minimap-element.js @@ -4,7 +4,6 @@ import { CompositeDisposable, Disposable } from 'atom' import { EventsDelegation, AncestorsMethods } from 'atom-utils-plus' import elementResizeDetectorImport from 'element-resize-detector' -import * as Main from './main' import CanvasDrawer from './mixins/canvas-drawer' import include from './decorators/include' import element from './decorators/element' @@ -707,7 +706,7 @@ class MinimapElement { this.pendingFrontDecorationChanges.push(change) } this.requestUpdate() - }), + }) ) this.setStandAlone(this.minimap.isStandAlone())