fix embedded workbench
This commit is contained in:
parent
69ba2d1d66
commit
9d595de806
|
|
@ -21,6 +21,7 @@ import './embeddedWorkbenchLoader.css';
|
||||||
import { Workbench } from './workbench';
|
import { Workbench } from './workbench';
|
||||||
import { currentTheme, toggleTheme } from '@web/theme';
|
import { currentTheme, toggleTheme } from '@web/theme';
|
||||||
import type { SourceLocation } from './modelUtil';
|
import type { SourceLocation } from './modelUtil';
|
||||||
|
import { filePathToTraceURL } from './uiModeTraceView';
|
||||||
|
|
||||||
function openPage(url: string, target?: string) {
|
function openPage(url: string, target?: string) {
|
||||||
if (url)
|
if (url)
|
||||||
|
|
@ -40,7 +41,15 @@ export const EmbeddedWorkbenchLoader: React.FunctionComponent = () => {
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
window.addEventListener('message', async ({ data: { method, params } }) => {
|
window.addEventListener('message', async ({ data: { method, params } }) => {
|
||||||
if (method === 'loadTraceRequested') {
|
if (method === 'loadTraceRequested') {
|
||||||
setTraceURLs(params.traceUrl ? [params.traceUrl] : []);
|
if (params.traceUrl) {
|
||||||
|
// the param is called URL, but VS Code sends a path
|
||||||
|
const url = params.traceUrl.startsWith('http')
|
||||||
|
? params.traceUrl
|
||||||
|
: filePathToTraceURL(params.traceUrl).toString();
|
||||||
|
setTraceURLs([url]);
|
||||||
|
} else {
|
||||||
|
setTraceURLs([]);
|
||||||
|
}
|
||||||
setProcessingErrorMessage(null);
|
setProcessingErrorMessage(null);
|
||||||
} else if (method === 'applyTheme') {
|
} else if (method === 'applyTheme') {
|
||||||
if (currentTheme() !== params.theme)
|
if (currentTheme() !== params.theme)
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ function formatUrl(traceURL: URL) {
|
||||||
return traceURL;
|
return traceURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
function filePathToTraceURL(path: string) {
|
export function filePathToTraceURL(path: string) {
|
||||||
const url = new URL('file', location.href);
|
const url = new URL('file', location.href);
|
||||||
url.searchParams.set('path', path);
|
url.searchParams.set('path', path);
|
||||||
return url;
|
return url;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue