Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 90c9480

Browse files
committed
Make onDidChangeConfiguration inheritable
1 parent df68b0e commit 90c9480

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

‎src/webview/LeetCodeWebview.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@ export abstract class LeetCodeWebview implements Disposable {
1111
private listener: Disposable;
1212

1313
public initialize(context: ExtensionContext): void {
14+
const { onDidChangeConfiguration } = this.getWebviewOption();
1415
this.context = context;
15-
this.listener = workspace.onDidChangeConfiguration((event: ConfigurationChangeEvent) => {
16-
if (event.affectsConfiguration("markdown") && this.panel) {
17-
this.panel.webview.html = this.getWebviewContent();
18-
}
19-
}, this);
16+
if (onDidChangeConfiguration) {
17+
this.listener = workspace.onDidChangeConfiguration(onDidChangeConfiguration, this);
18+
} else {
19+
this.listener = workspace.onDidChangeConfiguration((event: ConfigurationChangeEvent) => {
20+
if (event.affectsConfiguration("markdown") && this.panel) {
21+
this.panel.webview.html = this.getWebviewContent();
22+
}
23+
}, this);
24+
}
2025
}
2126

2227
public dispose(): void {
@@ -28,9 +33,9 @@ export abstract class LeetCodeWebview implements Disposable {
2833

2934
protected showWebviewInternal(): this is { panel: WebviewPanel } {
3035
if (!this.panel) {
31-
const option: ILeetCodeWebviewOption = this.getWebviewOption();
36+
const { viewType, title, viewColumn, onDidReceiveMessage } = this.getWebviewOption();
3237

33-
this.panel = window.createWebviewPanel(option.viewType, option.title, option.viewColumn || ViewColumn.One, {
38+
this.panel = window.createWebviewPanel(viewType, title, viewColumn || ViewColumn.One, {
3439
enableScripts: true,
3540
enableCommandUris: true,
3641
enableFindWidget: true,
@@ -42,8 +47,8 @@ export abstract class LeetCodeWebview implements Disposable {
4247
this.panel = undefined;
4348
}, null, this.context.subscriptions);
4449

45-
if (option.onDidReceiveMessage) {
46-
this.panel.webview.onDidReceiveMessage(option.onDidReceiveMessage, this, this.context.subscriptions);
50+
if (onDidReceiveMessage) {
51+
this.panel.webview.onDidReceiveMessage(onDidReceiveMessage, this, this.context.subscriptions);
4752
}
4853
}
4954

@@ -61,4 +66,5 @@ export interface ILeetCodeWebviewOption {
6166
title: string;
6267
viewColumn?: ViewColumn;
6368
onDidReceiveMessage?: (message: any) => Promise<void>;
69+
onDidChangeConfiguration?: (event: ConfigurationChangeEvent) => Promise<void>;
6470
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /