Skip to content

Commit 870884b

Browse files
committed
🎨 Minor code cleanup
1 parent 01031e3 commit 870884b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/components/editor/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@ const Editor: Component<Props> = (props) => {
2929

3030
if (props.formatter) {
3131
languages.registerDocumentFormattingEditProvider('typescript', {
32-
provideDocumentFormattingEdits: async (model) => {
32+
async provideDocumentFormattingEdits(model) {
3333
props.formatter!.postMessage({
3434
event: 'FORMAT',
3535
code: model.getValue(),
3636
pos: editor.getPosition(),
3737
});
38+
3839
return new Promise((resolve, reject) => {
3940
props.formatter!.addEventListener(
4041
'message',
@@ -72,11 +73,14 @@ const Editor: Component<Props> = (props) => {
7273
enabled: props.withMinimap,
7374
},
7475
});
76+
7577
editor.onDidChangeModelContent(() => {
7678
props.onDocChange?.(editor.getValue());
7779
});
80+
7881
props.ref?.(editor);
7982
};
83+
8084
// Initialize Monaco
8185
onMount(() => setupEditor());
8286
onCleanup(() => editor?.dispose());
@@ -85,9 +89,11 @@ const Editor: Component<Props> = (props) => {
8589
editor.setModel(model());
8690
liftOff();
8791
});
92+
8893
createEffect(() => {
8994
mEditor.setTheme(props.isDark ? 'vs-dark-plus' : 'vs-light-plus');
9095
});
96+
9197
createEffect(() => {
9298
const fontSize = zoomState.fontSize;
9399
editor.updateOptions({ fontSize });

src/components/editor/setupSolid.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ editor.defineTheme('vs-dark-plus', vsDark as editor.IStandaloneThemeData);
9595
editor.defineTheme('vs-light-plus', vsLight as editor.IStandaloneThemeData);
9696

9797
const hookLanguages = languages.setLanguageConfiguration;
98+
9899
languages.setLanguageConfiguration = (
99100
languageId: string,
100101
configuration: languages.LanguageConfiguration,
@@ -105,8 +106,8 @@ languages.setLanguageConfiguration = (
105106

106107
export async function liftOff(): Promise<void> {
107108
await loadingWasm;
109+
108110
// wireTmGrammars only cares about the language part, but asks for all of monaco
109111
// we fool it by just passing in an object with languages
110-
111112
await wireTmGrammars({ languages } as any, registry, grammars);
112113
}

0 commit comments

Comments
 (0)