Skip to content

Commit 035a457

Browse files
authored
Merge pull request #785 from UziTech/update-styles
2 parents c0778a6 + 6ec34b6 commit 035a457

File tree

7 files changed

+103
-7103
lines changed

7 files changed

+103
-7103
lines changed

.github/workflows/CI.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,29 @@ jobs:
4242
Lint:
4343
if: "!contains(github.event.head_commit.message, '[skip ci]')"
4444
runs-on: ubuntu-latest
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4547
steps:
4648
- uses: actions/checkout@v2
4749
with:
4850
fetch-depth: 0
49-
- uses: actions/setup-node@v2
51+
- name: Commit lint ✨
52+
uses: wagoid/commitlint-github-action@v2
53+
54+
- uses: UziTech/action-setup-atom@v1
55+
- name: Setup PNPM
56+
uses: pnpm/[email protected]
5057
with:
51-
node-version: "12.x"
52-
- name: Install NPM dependencies
53-
run: |
54-
npm install --ignore-scripts
58+
version: latest
59+
60+
- name: Install dependencies
61+
run: pnpm install
62+
63+
- name: Format ✨
64+
run: pnpm test.format
65+
5566
- name: Lint ✨
56-
run: npm run test:lint
67+
run: pnpm test.lint
5768

5869
Release:
5970
needs: [Test, Lint]

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
public-hoist-pattern[]=*
2+
package-lock=false
3+
lockfile=true

lib/deps/underscore-plus.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,13 @@ export function dasherize(string) {
2222
}
2323
})
2424
}
25+
26+
export function debounce(callback, wait) {
27+
let timeoutId = null
28+
return (...args) => {
29+
clearTimeout(timeoutId)
30+
timeoutId = setTimeout(() => {
31+
callback.apply(null, args)
32+
}, wait)
33+
}
34+
}

lib/main.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import config from "./config.json"
77
import * as PluginManagement from "./plugin-management"
88
import { treeSitterWarning } from "./performance-monitor"
99
import DOMStylesReader from "./dom-styles-reader"
10+
import { debounce } from "./deps/underscore-plus"
1011

1112
export { default as config } from "./config.json"
1213
export * from "./plugin-management"
@@ -398,6 +399,7 @@ export function observeMinimaps(iterator) {
398399
* @access private
399400
*/
400401
function initSubscriptions() {
402+
const debounceUpdateStyles = debounce(updateStyles, 300)
401403
subscriptions.add(
402404
atom.workspace.observeTextEditors((textEditor) => {
403405
const minimap = minimapForEditor(textEditor)
@@ -407,16 +409,24 @@ function initSubscriptions() {
407409
minimapElement.attach(textEditor.getElement())
408410
}),
409411
// empty color cache if the theme changes
410-
atom.themes.onDidChangeActiveThemes(() => {
411-
domStylesReader.invalidateDOMStylesCache()
412-
editorsMinimaps.forEach((minimap) => {
413-
atom.views.getView(minimap).requestForcedUpdate()
414-
})
415-
}),
412+
atom.themes.onDidChangeActiveThemes(debounceUpdateStyles),
413+
atom.styles.onDidUpdateStyleElement(debounceUpdateStyles),
414+
atom.styles.onDidAddStyleElement(debounceUpdateStyles),
415+
atom.styles.onDidRemoveStyleElement(debounceUpdateStyles),
416416
treeSitterWarning()
417417
)
418418
}
419419

420+
/**
421+
* Force update styles of minimap
422+
*/
423+
function updateStyles() {
424+
domStylesReader.invalidateDOMStylesCache()
425+
editorsMinimaps.forEach((minimap) => {
426+
atom.views.getView(minimap).requestForcedUpdate()
427+
})
428+
}
429+
420430
// The public exports included in the service:
421431
const MinimapServiceV1 = {
422432
minimapViewProvider,

0 commit comments

Comments
 (0)