Use viewType instead of uri for webviews

As discussed in #45994, move from using a uri to using a viewType. The view type is shared among all webviews of a given type, such as all markdown previews

Fixes #44575
This commit is contained in:
Matt Bierner
2018-03-20 14:44:10 -07:00
parent 18146e8c71
commit ea1fed9616
6 changed files with 27 additions and 21 deletions

View File

@@ -18,10 +18,8 @@ const localize = nls.loadMessageBundle();
export class MarkdownPreview {
public static previewScheme = 'vscode-markdown-preview';
private static previewCount = 0;
public static previewViewType = 'markdown.preview';
public readonly uri: vscode.Uri;
private readonly webview: vscode.Webview;
private throttleTimer: any;
private initialLine: number | undefined = undefined;
@@ -41,9 +39,8 @@ export class MarkdownPreview {
topmostLineMonitor: MarkdownFileTopmostLineMonitor,
private readonly contributions: MarkdownContributions
) {
this.uri = vscode.Uri.parse(`${MarkdownPreview.previewScheme}:${MarkdownPreview.previewCount++}`);
this.webview = vscode.window.createWebview(
this.uri,
MarkdownPreview.previewViewType,
this.getPreviewTitle(this._resource),
previewColumn, {
enableScripts: true,