Add WebviewView.description

Allow configuring the description for webview views.

This is rendered next to the title in a less prominently in the title
This commit is contained in:
Matt Bierner
2020-09-08 15:23:43 -07:00
parent 1fbd17331e
commit 4c7071e9ab
6 changed files with 45 additions and 8 deletions

View File

@@ -29,13 +29,15 @@ export class MainThreadWebviewsViews extends Disposable implements extHostProtoc
}
public $setWebviewViewTitle(handle: extHostProtocol.WebviewHandle, value: string | undefined): void {
const webviewView = this._webviewViews.get(handle);
if (!webviewView) {
throw new Error('unknown webview view');
}
const webviewView = this.getWebviewView(handle);
webviewView.title = value;
}
public $setWebviewViewDescription(handle: extHostProtocol.WebviewHandle, value: string | undefined): void {
const webviewView = this.getWebviewView(handle);
webviewView.description = value;
}
public $registerWebviewViewProvider(viewType: string, options?: { retainContextWhenHidden?: boolean }): void {
if (this._webviewViewProviders.has(viewType)) {
throw new Error(`View provider for ${viewType} already registered`);
@@ -89,5 +91,13 @@ export class MainThreadWebviewsViews extends Disposable implements extHostProtoc
provider.dispose();
this._webviewViewProviders.delete(viewType);
}
private getWebviewView(handle: string): WebviewView {
const webviewView = this._webviewViews.get(handle);
if (!webviewView) {
throw new Error('unknown webview view');
}
return webviewView;
}
}