Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hiding of image preview status bar items #161278

Merged
merged 1 commit into from Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions extensions/image-preview/src/imagePreview/index.ts
Expand Up @@ -119,6 +119,12 @@ class ImagePreview extends MediaPreview {
this.webviewEditor.webview.postMessage({ type: 'setActive', value: this.webviewEditor.active });
}

public override dispose(): void {
super.dispose();
this.sizeStatusBarEntry.hide(this);
this.zoomStatusBarEntry.hide(this);
}

public zoomIn() {
if (this.previewState === PreviewState.Active) {
this.webviewEditor.webview.postMessage({ type: 'zoomIn' });
Expand Down
9 changes: 6 additions & 3 deletions extensions/image-preview/src/mediaPreview.ts
Expand Up @@ -48,10 +48,8 @@ export abstract class MediaPreview extends Disposable {
}));

this._register(webviewEditor.onDidDispose(() => {
if (this.previewState === PreviewState.Active) {
this.binarySizeStatusBarEntry.hide(this);
}
this.previewState = PreviewState.Disposed;
this.dispose();
}));

const watcher = this._register(vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(resource, '*')));
Expand All @@ -69,6 +67,11 @@ export abstract class MediaPreview extends Disposable {
}));
}

public override dispose() {
super.dispose();
this.binarySizeStatusBarEntry.hide(this);
}

protected updateBinarySize() {
vscode.workspace.fs.stat(this.resource).then(({ size }) => {
this._binarySize = size;
Expand Down