Skip to content

Commit 3d0bcc1

Browse files
committed
Fix formatting
1 parent 935f194 commit 3d0bcc1

File tree

3 files changed

+58
-58
lines changed

3 files changed

+58
-58
lines changed

src/webview/helper.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { Uri, Webview } from "vscode";
22

33
export function getUri(webview: Webview, extensionUri: Uri, pathList: string[]) {
4-
return webview.asWebviewUri(Uri.joinPath(extensionUri, ...pathList));
4+
return webview.asWebviewUri(Uri.joinPath(extensionUri, ...pathList));
55
}
66

77
export function getNonce() {
8-
let text = "";
9-
const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
10-
for (let i = 0; i < 32; i++) {
11-
text += possible.charAt(Math.floor(Math.random() * possible.length));
12-
}
13-
return text;
8+
let text = "";
9+
const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
10+
for (let i = 0; i < 32; i++) {
11+
text += possible.charAt(Math.floor(Math.random() * possible.length));
12+
}
13+
return text;
1414
}

src/webview/messaging.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import { ExtensionContext, Webview, window } from "vscode";
22

33
import type { Endpoint } from "comlink/dist/esm/comlink";
44
export function getComlinkChannel(webview: Webview, context: ExtensionContext): Endpoint {
5-
return {
6-
addEventListener: (_type: string, listener: any) => webview.onDidReceiveMessage((msg) => listener({ data: msg, type: 'message' }), undefined, context.subscriptions),
7-
removeEventListener: (_type: string, _listener: any) => { /* nop */ },
8-
postMessage: (message) => {
9-
try {
10-
webview.postMessage(message);
11-
} catch (e: unknown) {
12-
window.showErrorMessage(`Failed to post message: ${(e as Error).message}`);
13-
}
14-
}
15-
};
5+
return {
6+
addEventListener: (_type: string, listener: any) => webview.onDidReceiveMessage((msg) => listener({ data: msg, type: 'message' }), undefined, context.subscriptions),
7+
removeEventListener: (_type: string, _listener: any) => { /* nop */ },
8+
postMessage: (message) => {
9+
try {
10+
webview.postMessage(message);
11+
} catch (e: unknown) {
12+
window.showErrorMessage(`Failed to post message: ${(e as Error).message}`);
13+
}
14+
}
15+
};
1616
}

src/webview/themes.ts

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,60 +5,60 @@ import { MonacoTheme } from "shared/src/index";
55

66

77
async function getCurrentThemeData(): Promise<object | undefined> {
8-
const config = workspace.getConfiguration();
9-
const theme = config.get('workbench.colorTheme') as string;
8+
const config = workspace.getConfiguration();
9+
const theme = config.get('workbench.colorTheme') as string;
1010

11-
const extension = extensions.all.find(ext => {
12-
const contributes = ext.packageJSON.contributes;
13-
return contributes && contributes.themes && contributes.themes.some((t: { label: string; }) => t.label === theme);
14-
});
11+
const extension = extensions.all.find(ext => {
12+
const contributes = ext.packageJSON.contributes;
13+
return contributes && contributes.themes && contributes.themes.some((t: { label: string; }) => t.label === theme);
14+
});
1515

16-
if (!extension) {
17-
return undefined;
18-
}
16+
if (!extension) {
17+
return undefined;
18+
}
1919

20-
const themeInfo = extension.packageJSON.contributes.themes.find((t: { label: string; }) => t.label === theme);
21-
const themePath = path.join(extension.extensionPath, themeInfo.path);
20+
const themeInfo = extension.packageJSON.contributes.themes.find((t: { label: string; }) => t.label === theme);
21+
const themePath = path.join(extension.extensionPath, themeInfo.path);
2222

23-
return JSON.parse(await readFile(themePath, 'utf8'));
23+
return JSON.parse(await readFile(themePath, 'utf8'));
2424
}
2525

2626
function convertVSCodeThemeToMonacoTheme(themeData: any): MonacoTheme {
27-
const monacoTheme = {
28-
base: getMonacoBaseTheme(themeData.type),
29-
inherit: true,
30-
rules: [] as any,
31-
colors: {} as any
32-
} as MonacoTheme;
27+
const monacoTheme = {
28+
base: getMonacoBaseTheme(themeData.type),
29+
inherit: true,
30+
rules: [] as any,
31+
colors: {} as any
32+
} as MonacoTheme;
3333

34-
monacoTheme.colors['editor.background'] = themeData.colors['editor.background'];
35-
monacoTheme.colors['editor.foreground'] = themeData.colors['editor.foreground'];
34+
monacoTheme.colors['editor.background'] = themeData.colors['editor.background'];
35+
monacoTheme.colors['editor.foreground'] = themeData.colors['editor.foreground'];
3636

37-
monacoTheme.rules = themeData.tokenColors?.map((token: any) => ({
38-
token: token.scope,
39-
foreground: token.settings.foreground,
40-
background: token.settings.background,
41-
fontStyle: token.settings.fontStyle
42-
})) ?? [];
37+
monacoTheme.rules = themeData.tokenColors?.map((token: any) => ({
38+
token: token.scope,
39+
foreground: token.settings.foreground,
40+
background: token.settings.background,
41+
fontStyle: token.settings.fontStyle
42+
})) ?? [];
4343

44-
return monacoTheme;
44+
return monacoTheme;
4545
}
4646

4747
function getMonacoBaseTheme(vscodeThemeType: string | MonacoTheme['base']): MonacoTheme['base'] {
48-
switch (vscodeThemeType) {
49-
case 'vs':
50-
case 'vs-dark':
51-
case 'hc-black':
52-
return vscodeThemeType;
53-
default:
54-
return 'vs-dark';
55-
}
48+
switch (vscodeThemeType) {
49+
case 'vs':
50+
case 'vs-dark':
51+
case 'hc-black':
52+
return vscodeThemeType;
53+
default:
54+
return 'vs-dark';
55+
}
5656
}
5757

5858
export async function getMonacoTheme() {
59-
const themeData = await getCurrentThemeData();
60-
if (!themeData) {
61-
throw new Error('Theme data is undefined');
62-
}
63-
return convertVSCodeThemeToMonacoTheme(themeData);
59+
const themeData = await getCurrentThemeData();
60+
if (!themeData) {
61+
throw new Error('Theme data is undefined');
62+
}
63+
return convertVSCodeThemeToMonacoTheme(themeData);
6464
}

0 commit comments

Comments
 (0)