@@ -6,6 +6,7 @@ import Minimap from './minimap'
66import config from './config.json'
77import * as PluginManagement from './plugin-management'
88import { treeSitterWarning } from './performance-monitor'
9+ import DOMStylesReader from './dom-styles-reader'
910
1011export { default as config } from './config.json'
1112export * from './plugin-management'
@@ -63,6 +64,12 @@ let subscriptionsOfCommands = null
6364 */
6465export const emitter = new Emitter ( )
6566
67+
68+ /**
69+ DOMStylesReader cache used for storing token colors
70+ */
71+ let DOMStylesReaderInstance = null
72+
6673/**
6774 * Activates the minimap package.
6875 */
@@ -85,6 +92,8 @@ export function activate () {
8592 } )
8693
8794 editorsMinimaps = new Map ( )
95+ DOMStylesReaderInstance = new DOMStylesReader ( )
96+
8897 subscriptions = new CompositeDisposable ( )
8998 active = true
9099
@@ -100,6 +109,8 @@ export function activate () {
100109export function minimapViewProvider ( model ) {
101110 if ( model instanceof Minimap ) {
102111 const element = new MinimapElement ( )
112+ // add DOMStylesReaderInstance
113+ element . DOMStylesReader = DOMStylesReaderInstance ;
103114 element . setModel ( model )
104115 return element
105116 }
@@ -125,6 +136,7 @@ export function deactivate () {
125136 subscriptionsOfCommands . dispose ( )
126137 subscriptionsOfCommands = null
127138 editorsMinimaps = undefined
139+ DOMStylesReaderInstance . invalidateDOMStylesCache ( )
128140 toggled = false
129141 active = false
130142}
@@ -153,6 +165,7 @@ export function toggle () {
153165 toggled = true
154166 initSubscriptions ( )
155167 }
168+ DOMStylesReaderInstance . invalidateDOMStylesCache ( )
156169}
157170
158171/**
@@ -358,6 +371,11 @@ function initSubscriptions () {
358371 emitter . emit ( 'did-create-minimap' , minimap )
359372 minimapElement . attach ( )
360373 } ) ,
374+ // empty color cache if the theme changes
375+ atom . themes . onDidChangeActiveThemes ( ( ) => {
376+ DOMStylesReaderInstance . invalidateDOMStylesCache ( )
377+ editorsMinimaps . forEach ( ( minimap ) => { atom . views . getView ( minimap ) . requestForcedUpdate ( ) } )
378+ } ) ,
361379 treeSitterWarning ( )
362380 )
363381}
0 commit comments