Merge from vscode c873727e8bac95e7cbf5b154a9e6ae0986f2ce18 (#6446)

This commit is contained in:
Anthony Dresser
2019-07-19 19:21:54 -07:00
committed by GitHub
parent 5c63f7bdb5
commit b21435743d
63 changed files with 2049 additions and 1000 deletions

View File

@@ -9,6 +9,7 @@ import { IEditorModel } from 'vs/platform/editor/common/editor';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
import { EditorInput, EditorModel, GroupIdentifier, IEditorInput } from 'vs/workbench/common/editor';
import { WebviewEditorOverlay } from 'vs/workbench/contrib/webview/common/webview';
import { UnownedDisposable as Unowned } from 'vs/base/common/lifecycle';
class WebviewIconsManager {
private readonly _icons = new Map<string, { light: URI, dark: URI }>();
@@ -58,6 +59,7 @@ export class WebviewEditorInput extends EditorInput {
private _name: string;
private _iconPath?: { light: URI, dark: URI };
private _group?: GroupIdentifier;
private readonly _webview: WebviewEditorOverlay;
constructor(
public readonly id: string,
@@ -67,14 +69,14 @@ export class WebviewEditorInput extends EditorInput {
readonly location: URI;
readonly id: ExtensionIdentifier;
},
public readonly webview: WebviewEditorOverlay,
webview: Unowned<WebviewEditorOverlay>,
) {
super();
this._name = name;
this.extension = extension;
this._register(webview); // The input owns this webview
this._webview = this._register(webview.acquire()); // The input owns this webview
}
public getTypeId(): string {
@@ -105,6 +107,10 @@ export class WebviewEditorInput extends EditorInput {
this._onDidChangeLabel.fire();
}
public get webview() {
return this._webview;
}
public get iconPath() {
return this._iconPath;
}
@@ -147,7 +153,7 @@ export class RevivedWebviewEditorInput extends WebviewEditorInput {
readonly id: ExtensionIdentifier
},
private readonly reviver: (input: WebviewEditorInput) => Promise<void>,
webview: WebviewEditorOverlay,
webview: Unowned<WebviewEditorOverlay>,
) {
super(id, viewType, name, extension, webview);
}

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { equals } from 'vs/base/common/arrays';
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { IDisposable, toDisposable, UnownedDisposable } from 'vs/base/common/lifecycle';
import { values } from 'vs/base/common/map';
import { URI } from 'vs/base/common/uri';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
@@ -144,7 +144,7 @@ export class WebviewEditorService implements IWebviewEditorService {
): WebviewEditorInput {
const webview = this.createWebiew(id, extension, options);
const webviewInput = this._instantiationService.createInstance(WebviewEditorInput, id, viewType, title, extension, webview);
const webviewInput = this._instantiationService.createInstance(WebviewEditorInput, id, viewType, title, extension, new UnownedDisposable(webview));
this._editorService.openEditor(webviewInput, { pinned: true, preserveFocus: showOptions.preserveFocus }, showOptions.group);
return webviewInput;
}
@@ -191,7 +191,7 @@ export class WebviewEditorService implements IWebviewEditorService {
const promise = new Promise<void>(r => { resolve = r; });
this._revivalPool.add(webview, resolve!);
return promise;
}, webview);
}, new UnownedDisposable(webview));
webviewInput.iconPath = iconPath;