mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 08:38:56 +01:00
Make sure we correctly update local resource roots when switching previewed markdown file
Fixes #49859
This commit is contained in:
@@ -54,13 +54,10 @@ export class MarkdownPreview {
|
||||
contentProvider,
|
||||
previewConfigurations,
|
||||
logger,
|
||||
topmostLineMonitor);
|
||||
topmostLineMonitor,
|
||||
contributions);
|
||||
|
||||
preview.editor.webview.options = {
|
||||
enableScripts: true,
|
||||
enableCommandUris: true,
|
||||
localResourceRoots: MarkdownPreview.getLocalResourceRoots(resource, contributions)
|
||||
};
|
||||
preview.editor.webview.options = MarkdownPreview.getWebviewOptions(resource, contributions);
|
||||
|
||||
if (!isNaN(line)) {
|
||||
preview.line = line;
|
||||
@@ -83,10 +80,8 @@ export class MarkdownPreview {
|
||||
MarkdownPreview.viewType,
|
||||
MarkdownPreview.getPreviewTitle(resource, locked),
|
||||
previewColumn, {
|
||||
enableScripts: true,
|
||||
enableCommandUris: true,
|
||||
enableFindWidget: true,
|
||||
localResourceRoots: MarkdownPreview.getLocalResourceRoots(resource, contributions)
|
||||
...MarkdownPreview.getWebviewOptions(resource, contributions)
|
||||
});
|
||||
|
||||
return new MarkdownPreview(
|
||||
@@ -96,7 +91,8 @@ export class MarkdownPreview {
|
||||
contentProvider,
|
||||
previewConfigurations,
|
||||
logger,
|
||||
topmostLineMonitor);
|
||||
topmostLineMonitor,
|
||||
contributions);
|
||||
}
|
||||
|
||||
private constructor(
|
||||
@@ -106,7 +102,8 @@ export class MarkdownPreview {
|
||||
private readonly _contentProvider: MarkdownContentProvider,
|
||||
private readonly _previewConfigurations: MarkdownPreviewConfigurationManager,
|
||||
private readonly _logger: Logger,
|
||||
topmostLineMonitor: MarkdownFileTopmostLineMonitor
|
||||
topmostLineMonitor: MarkdownFileTopmostLineMonitor,
|
||||
private readonly _contributions: MarkdownContributions,
|
||||
) {
|
||||
this._resource = resource;
|
||||
this._locked = locked;
|
||||
@@ -245,10 +242,6 @@ export class MarkdownPreview {
|
||||
return this.editor.viewColumn;
|
||||
}
|
||||
|
||||
public isWebviewOf(webview: vscode.WebviewPanel): boolean {
|
||||
return this.editor === webview;
|
||||
}
|
||||
|
||||
public matchesResource(
|
||||
otherResource: vscode.Uri,
|
||||
otherPosition: vscode.ViewColumn | undefined,
|
||||
@@ -334,10 +327,22 @@ export class MarkdownPreview {
|
||||
const content = await this._contentProvider.provideTextDocumentContent(document, this._previewConfigurations, this.line, this.state);
|
||||
if (this._resource === resource) {
|
||||
this.editor.title = MarkdownPreview.getPreviewTitle(this._resource, this._locked);
|
||||
this.editor.webview.options = MarkdownPreview.getWebviewOptions(resource, this._contributions);
|
||||
this.editor.webview.html = content;
|
||||
}
|
||||
}
|
||||
|
||||
private static getWebviewOptions(
|
||||
resource: vscode.Uri,
|
||||
contributions: MarkdownContributions
|
||||
): vscode.WebviewOptions {
|
||||
return {
|
||||
enableScripts: true,
|
||||
enableCommandUris: true,
|
||||
localResourceRoots: MarkdownPreview.getLocalResourceRoots(resource, contributions)
|
||||
};
|
||||
}
|
||||
|
||||
private static getLocalResourceRoots(
|
||||
resource: vscode.Uri,
|
||||
contributions: MarkdownContributions
|
||||
|
||||
Reference in New Issue
Block a user