提交 253434c8 编写于 作者: M Matt Bierner

Fix webview protocol logic for windows

Fixes #41795

Make sure we use the correct path seps and normalization on windows for the new webview protocol
上级 e9a2ebe2
...@@ -53,6 +53,7 @@ import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRe ...@@ -53,6 +53,7 @@ import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRe
import { Color } from 'vs/base/common/color'; import { Color } from 'vs/base/common/color';
import { WorkbenchTree, IListService } from 'vs/platform/list/browser/listService'; import { WorkbenchTree, IListService } from 'vs/platform/list/browser/listService';
import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import URI from 'vs/base/common/uri';
/** A context key that is set when an extension editor webview has focus. */ /** A context key that is set when an extension editor webview has focus. */
export const KEYBINDING_CONTEXT_EXTENSIONEDITOR_WEBVIEW_FOCUS = new RawContextKey<boolean>('extensionEditorWebviewFocus', undefined); export const KEYBINDING_CONTEXT_EXTENSIONEDITOR_WEBVIEW_FOCUS = new RawContextKey<boolean>('extensionEditorWebviewFocus', undefined);
...@@ -67,7 +68,7 @@ function renderBody( ...@@ -67,7 +68,7 @@ function renderBody(
body: string, body: string,
environmentService: IEnvironmentService environmentService: IEnvironmentService
): string { ): string {
const styleSheetPath = require.toUrl('./media/markdown.css').replace('file://' + environmentService.appRoot, 'vscode-core-resource://'); const styleSheetPath = require.toUrl('./media/markdown.css').replace(URI.file(environmentService.appRoot).toString(true), 'vscode-core-resource://');
return `<!DOCTYPE html> return `<!DOCTYPE html>
<html> <html>
<head> <head>
......
...@@ -15,7 +15,7 @@ import { WebviewFindWidget } from './webviewFindWidget'; ...@@ -15,7 +15,7 @@ import { WebviewFindWidget } from './webviewFindWidget';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView'; import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IContextKey } from 'vs/platform/contextkey/common/contextkey'; import { IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { normalize, join } from 'vs/base/common/paths'; import { normalize, join, nativeSep } from 'vs/base/common/paths';
import { startsWith } from 'vs/base/common/strings'; import { startsWith } from 'vs/base/common/strings';
export interface WebviewElementFindInPageOptions { export interface WebviewElementFindInPageOptions {
...@@ -102,7 +102,7 @@ export default class Webview { ...@@ -102,7 +102,7 @@ export default class Webview {
const contents = this._webview.getWebContents(); const contents = this._webview.getWebContents();
if (contents && !contents.isDestroyed()) { if (contents && !contents.isDestroyed()) {
registerFileProtocol(contents, 'vscode-core-resource', this._environmentService.appRoot); registerFileProtocol(contents, 'vscode-core-resource', this._environmentService.appRoot + nativeSep);
} }
})); }));
} }
...@@ -421,7 +421,8 @@ function registerFileProtocol( ...@@ -421,7 +421,8 @@ function registerFileProtocol(
) { ) {
contents.session.protocol.registerFileProtocol(protocol, (request, callback: any) => { contents.session.protocol.registerFileProtocol(protocol, (request, callback: any) => {
const requestPath = URI.parse(request.url).path; const requestPath = URI.parse(request.url).path;
const normalizedPath = normalize(join(root, requestPath)); const normalizedPath = normalize(join(root, requestPath), true);
console.log(root, requestPath, normalizedPath);
if (startsWith(normalizedPath, root)) { if (startsWith(normalizedPath, root)) {
callback({ path: normalizedPath }); callback({ path: normalizedPath });
} else { } else {
......
...@@ -28,13 +28,14 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment' ...@@ -28,13 +28,14 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import { onUnexpectedError } from 'vs/base/common/errors'; import { onUnexpectedError } from 'vs/base/common/errors';
import { addGAParameters } from 'vs/platform/telemetry/node/telemetryNodeUtils'; import { addGAParameters } from 'vs/platform/telemetry/node/telemetryNodeUtils';
import { generateTokensCSSForColorMap } from 'vs/editor/common/modes/supports/tokenization'; import { generateTokensCSSForColorMap } from 'vs/editor/common/modes/supports/tokenization';
import URI from 'vs/base/common/uri';
function renderBody( function renderBody(
body: string, body: string,
css: string, css: string,
environmentService: IEnvironmentService environmentService: IEnvironmentService
): string { ): string {
const styleSheetPath = require.toUrl('./media/markdown.css').replace('file://' + environmentService.appRoot, 'vscode-core-resource://'); const styleSheetPath = require.toUrl('./media/markdown.css').replace(URI.file(environmentService.appRoot).toString(true), 'vscode-core-resource://');
return `<!DOCTYPE html> return `<!DOCTYPE html>
<html> <html>
<head> <head>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册