From 10730c9c167a33f6d5dc0eead62720af10afb7e4 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Mon, 11 Jan 2021 21:07:16 -0600 Subject: [PATCH] fix: import domStylesReader --- lib/main.js | 12 +++++------- lib/mixins/canvas-drawer.js | 7 ++++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/main.js b/lib/main.js index f4acb919..b5f02759 100644 --- a/lib/main.js +++ b/lib/main.js @@ -68,7 +68,7 @@ export const emitter = new Emitter() /** DOMStylesReader cache used for storing token colors */ -let DOMStylesReaderInstance = null +export let domStylesReader = null /** * Activates the minimap package. @@ -92,7 +92,7 @@ export function activate () { }) editorsMinimaps = new Map() - DOMStylesReaderInstance = new DOMStylesReader() + domStylesReader = new DOMStylesReader() subscriptions = new CompositeDisposable() active = true @@ -109,8 +109,6 @@ export function activate () { export function minimapViewProvider (model) { if (model instanceof Minimap) { const element = new MinimapElement() - // add DOMStylesReaderInstance - element.DOMStylesReader = DOMStylesReaderInstance; element.setModel(model) return element } @@ -136,7 +134,7 @@ export function deactivate () { subscriptionsOfCommands.dispose() subscriptionsOfCommands = null editorsMinimaps = undefined - DOMStylesReaderInstance.invalidateDOMStylesCache() + domStylesReader.invalidateDOMStylesCache() toggled = false active = false } @@ -165,7 +163,7 @@ export function toggle () { toggled = true initSubscriptions() } - DOMStylesReaderInstance.invalidateDOMStylesCache() + domStylesReader.invalidateDOMStylesCache() } /** @@ -373,7 +371,7 @@ function initSubscriptions () { }), // empty color cache if the theme changes atom.themes.onDidChangeActiveThemes(() => { - DOMStylesReaderInstance.invalidateDOMStylesCache() + domStylesReader.invalidateDOMStylesCache() editorsMinimaps.forEach((minimap) => { atom.views.getView(minimap).requestForcedUpdate() }) }), treeSitterWarning() diff --git a/lib/mixins/canvas-drawer.js b/lib/mixins/canvas-drawer.js index 4832a331..d1a0af12 100644 --- a/lib/mixins/canvas-drawer.js +++ b/lib/mixins/canvas-drawer.js @@ -4,6 +4,7 @@ import { escapeRegExp } from 'underscore-plus' import Mixin from 'mixto' import * as Main from '../main' +import { domStylesReader } from '../main' import CanvasLayer from '../canvas-layer' const SPEC_MODE = atom.inSpecMode() @@ -303,7 +304,7 @@ export default class CanvasDrawer extends Mixin { * @return {string} a CSS color */ getDefaultColor (editorElement) { - const color = this.DOMStylesReader.retrieveStyleFromDom(['.editor'], 'color', editorElement, true) + const color = domStylesReader.retrieveStyleFromDom(['.editor'], 'color', editorElement, true) return transparentize(color, this.textOpacity) } @@ -318,7 +319,7 @@ export default class CanvasDrawer extends Mixin { * @return {string} the CSS color for the provided token */ getTokenColor (scopes, editorElement) { - const color = this.DOMStylesReader.retrieveStyleFromDom(scopes, 'color', editorElement, true) + const color = domStylesReader.retrieveStyleFromDom(scopes, 'color', editorElement, true) return transparentize(color, this.textOpacity) } @@ -340,7 +341,7 @@ export default class CanvasDrawer extends Mixin { if (properties.scope) { const scopeString = properties.scope.split(oneOrMoreWhiteSpaceRegexp) - return this.DOMStylesReader.retrieveStyleFromDom(scopeString, 'background-color', editorElement, true) + return domStylesReader.retrieveStyleFromDom(scopeString, 'background-color', editorElement, true) } else { return this.getDefaultColor(editorElement) }