Skip to content

Commit aaa01ea

Browse files
committed
Make previewManager implement WebviewEditorProvider directly
1 parent f085deb commit aaa01ea

2 files changed

Lines changed: 6 additions & 12 deletions

File tree

extensions/image-preview/src/extension.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ export function activate(context: vscode.ExtensionContext) {
2323

2424
const previewManager = new PreviewManager(extensionRoot, sizeStatusBarEntry, binarySizeStatusBarEntry, zoomStatusBarEntry);
2525

26-
context.subscriptions.push(vscode.window.registerWebviewEditorProvider(
27-
PreviewManager.viewType,
28-
{
29-
async resolveWebviewEditor({ resource }, editor: vscode.WebviewPanel): Promise<vscode.WebviewEditorCapabilities> {
30-
return previewManager.resolve(resource, editor);
31-
}
32-
}));
26+
context.subscriptions.push(vscode.window.registerWebviewEditorProvider(PreviewManager.viewType, previewManager));
3327

3428
context.subscriptions.push(vscode.commands.registerCommand('imagePreview.zoomIn', () => {
3529
previewManager.activePreview?.zoomIn();

extensions/image-preview/src/preview.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { BinarySizeStatusBarEntry } from './binarySizeStatusBarEntry';
1313
const localize = nls.loadMessageBundle();
1414

1515

16-
export class PreviewManager {
16+
export class PreviewManager implements vscode.WebviewEditorProvider {
1717

1818
public static readonly viewType = 'imagePreview.previewEditor';
1919

@@ -27,11 +27,11 @@ export class PreviewManager {
2727
private readonly zoomStatusBarEntry: ZoomStatusBarEntry,
2828
) { }
2929

30-
public resolve(
31-
resource: vscode.Uri,
30+
public async resolveWebviewEditor(
31+
input: { readonly resource: vscode.Uri, },
3232
webviewEditor: vscode.WebviewPanel,
33-
): vscode.WebviewEditorCapabilities {
34-
const preview = new Preview(this.extensionRoot, resource, webviewEditor, this.sizeStatusBarEntry, this.binarySizeStatusBarEntry, this.zoomStatusBarEntry);
33+
): Promise<vscode.WebviewEditorCapabilities> {
34+
const preview = new Preview(this.extensionRoot, input.resource, webviewEditor, this.sizeStatusBarEntry, this.binarySizeStatusBarEntry, this.zoomStatusBarEntry);
3535
this._previews.add(preview);
3636
this.setActivePreview(preview);
3737

0 commit comments

Comments
 (0)