Skip to content

Commit

Permalink
feat: empty color cache if the theme changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jan 11, 2021
1 parent a605d57 commit 5b12790
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
5 changes: 5 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,11 @@ function initSubscriptions () {
emitter.emit('did-create-minimap', minimap)
minimapElement.attach()
}),
// empty color cache if the theme changes
atom.themes.onDidChangeActiveThemes(() => {
DOMStylesReaderInstance.invalidateDOMStylesCache()
editorsMinimaps.forEach((minimap) => { atom.views.getView(minimap).requestForcedUpdate() })
}),
treeSitterWarning()
)
}
Expand Down
12 changes: 0 additions & 12 deletions lib/minimap-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,18 +377,6 @@ class MinimapElement {
}

this.subscriptions.add(

/*
We use `atom.styles.onDidAddStyleElement` instead of
`atom.themes.onDidChangeActiveThemes`.
Why? Currently, The style element will be removed first, and then re-added
and the `change` event has not be triggered in the process.
*/
atom.styles.onDidAddStyleElement(() => {
this.DOMStylesReader.invalidateDOMStylesCache()
this.requestForcedUpdate()
}),

this.subscribeToMediaQuery()
)
}
Expand Down
4 changes: 1 addition & 3 deletions spec/minimap-element-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1198,9 +1198,7 @@ describe('MinimapElement', () => {
spyOn(minimapElement, 'requestForcedUpdate').andCallThrough()
spyOn(minimapElement.DOMStylesReader, 'invalidateDOMStylesCache').andCallThrough()

const styleNode = document.createElement('style')
styleNode.textContent = 'body{ color: #233 }'
atom.styles.emitter.emit('did-add-style-element', styleNode)
atom.themes.emitter.emit('did-change-active-themes')
})

waitsFor('minimap frame requested', () => {
Expand Down

0 comments on commit 5b12790

Please sign in to comment.