Skip to content

Commit

Permalink
fix #107438.
Browse files Browse the repository at this point in the history
  • Loading branch information
rebornix committed Oct 2, 2020
1 parent dfa980e commit 8284242
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/
import { dirname, joinPath } from 'vs/base/common/resources';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { preloadsScriptStr } from 'vs/workbench/contrib/notebook/browser/view/renderers/webviewPreloads';
import { Schemas } from 'vs/base/common/network';
import { FileAccess, Schemas } from 'vs/base/common/network';
import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
import { IFileService } from 'vs/platform/files/common/files';
import { VSBuffer } from 'vs/base/common/buffer';
Expand Down Expand Up @@ -356,9 +356,6 @@ export class BackLayerWebView extends Disposable {
}

async createWebview(): Promise<void> {
const pathsPath = getPathFromAmdModule(require, 'vs/loader.js');
const loader = asWebviewUri(this.environmentService, this.id, URI.file(pathsPath));

let coreDependencies = '';
let resolveFunc: () => void;

Expand All @@ -369,6 +366,9 @@ export class BackLayerWebView extends Disposable {
const baseUrl = asWebviewUri(this.environmentService, this.id, dirname(this.documentUri));

if (!isWeb) {
const loaderUri = FileAccess.asFileUri('vs/loader.js', require);
const loader = asWebviewUri(this.environmentService, this.id, loaderUri);

coreDependencies = `<script src="${loader}"></script><script>
var requirejs = (function() {
return require;
Expand All @@ -378,7 +378,9 @@ export class BackLayerWebView extends Disposable {
this.initialize(htmlContent);
resolveFunc!();
} else {
fetch(pathsPath).then(async response => {
const loaderUri = FileAccess.asBrowserUri('vs/loader.js', require);

fetch(loaderUri.toString(true)).then(async response => {
if (response.status !== 200) {
throw new Error(response.statusText);
}
Expand Down Expand Up @@ -555,7 +557,9 @@ var requirejs = (function() {
}

private _createInset(webviewService: IWebviewService, content: string) {
const rootPath = URI.file(path.dirname(getPathFromAmdModule(require, '')));
const rootPathStr = path.dirname(FileAccess.asFileUri('', require).fsPath);

const rootPath = isWeb ? FileAccess.asBrowserUri(rootPathStr, require) : FileAccess.asFileUri(rootPathStr, require);
const workspaceFolders = this.contextService.getWorkspace().folders.map(x => x.uri);

this.localResourceRootsCache = [...this.notebookService.getNotebookProviderResourceRoots(), ...workspaceFolders, rootPath];
Expand Down

0 comments on commit 8284242

Please sign in to comment.