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