Skip to content

Commit 457dd60

Browse files
committed
cleanup PR
1 parent 97a491e commit 457dd60

File tree

4 files changed

+38
-17
lines changed

4 files changed

+38
-17
lines changed

.github/workflows/checkPR.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Run Checks and Tests on PR
2+
3+
on: pull_request
4+
5+
jobs:
6+
check:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v4
12+
13+
- name: Install Bun
14+
uses: oven-sh/setup-bun@v1
15+
with:
16+
bun-version: latest
17+
18+
- name: Install Dependencies
19+
id: build
20+
run: |
21+
bun install
22+
23+
- name: Run Checks
24+
run: |
25+
bun run check

src/Highlighter.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type ShikiPlugin from 'src/main';
33
import {
44
bundledLanguages,
55
createHighlighter,
6-
type DynamicImportLanguageRegistration,
76
type LanguageRegistration,
87
type Highlighter,
98
type TokensResult,
@@ -55,10 +54,7 @@ export class CodeHighlighter {
5554
await this.loadEC();
5655
await this.loadShiki();
5756

58-
this.supportedLanguages = [
59-
...Object.keys(bundledLanguages),
60-
...this.customLanguages.map(i => i.name)
61-
];
57+
this.supportedLanguages = [...Object.keys(bundledLanguages), ...this.customLanguages.map(i => i.name)];
6258
}
6359

6460
async unload(): Promise<void> {
@@ -215,7 +211,7 @@ export class CodeHighlighter {
215211
if (!this.obsidianSafeLanguageNames().includes(lang)) {
216212
return undefined;
217213
}
218-
// load bundled language ​​when needed
214+
// load bundled language when needed
219215
if (!this.shiki.getLoadedLanguages().includes(lang)) {
220216
await this.shiki.loadLanguage(lang as BundledLanguage);
221217
}

src/codemirror/Cm6_ViewPlugin.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ export function createCm6Plugin(plugin: ShikiPlugin) {
2727
constructor(view: EditorView) {
2828
this.view = view;
2929
this.decorations = Decoration.none;
30-
this.updateWidgets(view);
30+
void this.updateWidgets(view);
3131

32-
plugin.updateCm6Plugin = (): void => {
33-
this.forceUpdate();
32+
plugin.updateCm6Plugin = (): Promise<void> => {
33+
return this.forceUpdate();
3434
};
3535
}
3636

@@ -46,12 +46,12 @@ export function createCm6Plugin(plugin: ShikiPlugin) {
4646
// we handle doc changes and selection changes here
4747
if (update.docChanged || update.selectionSet) {
4848
this.view = update.view;
49-
this.updateWidgets(update.view, update.docChanged);
49+
void this.updateWidgets(update.view, update.docChanged);
5050
}
5151
}
5252

53-
forceUpdate(): void {
54-
this.updateWidgets(this.view);
53+
async forceUpdate(): Promise<void> {
54+
await this.updateWidgets(this.view);
5555

5656
this.view.dispatch(this.view.state.update({}));
5757
}
@@ -70,7 +70,7 @@ export function createCm6Plugin(plugin: ShikiPlugin) {
7070
async updateWidgets(view: EditorView, docChanged: boolean = true): Promise<void> {
7171
let lang = '';
7272
let state: SyntaxNode[] = [];
73-
let decoQueue: DecoQueueNode[] = [];
73+
const decoQueue: DecoQueueNode[] = [];
7474

7575
// const t1 = performance.now();
7676

@@ -98,7 +98,7 @@ export function createCm6Plugin(plugin: ShikiPlugin) {
9898
lang: match[1],
9999
content: match[2],
100100
hideLang: this.isLivePreview(view.state) && !hasSelectionOverlap,
101-
hideTo: node.from + match[1].length + 3 // hide `{lang} `
101+
hideTo: node.from + match[1].length + 3, // hide `{lang} `
102102
});
103103
}
104104
} else {
@@ -135,7 +135,7 @@ export function createCm6Plugin(plugin: ShikiPlugin) {
135135
from: start,
136136
to: end,
137137
lang,
138-
content: Cm6_Util.getContent(view.state, start, end)
138+
content: Cm6_Util.getContent(view.state, start, end),
139139
});
140140
}
141141

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default class ShikiPlugin extends Plugin {
1313
activeCodeBlocks!: Map<string, CodeBlock[]>;
1414
settings!: Settings;
1515
loadedSettings!: Settings;
16-
updateCm6Plugin!: () => void;
16+
updateCm6Plugin!: () => Promise<void>;
1717

1818
codeBlockProcessors: MarkdownPostProcessor[] = [];
1919

@@ -65,7 +65,7 @@ export default class ShikiPlugin extends Plugin {
6565
}
6666
}
6767

68-
this.updateCm6Plugin();
68+
await this.updateCm6Plugin();
6969
}
7070

7171
async registerPrismPlugin(): Promise<void> {

0 commit comments

Comments
 (0)