From bce82f92b2dbc154a5f5c2608c02ba4ab9488417 Mon Sep 17 00:00:00 2001 From: barki mustapha Date: Tue, 2 Dec 2025 03:38:18 +0000 Subject: [PATCH] feat(devex): Improve "Open in Editor" diagnostics This commit enhances the "Open in Editor" feature by providing more informative error messages and adding detailed diagnostic logging. These changes will help users troubleshoot path mapping issues more effectively. Key changes: - Updated the error message in `onSocketOpeninEditor` to suggest configuring the `pathMapping` in `launch.json`. - Improved the error message in `parseUrlToUri` to provide a clearer explanation of the issue and suggest a solution. - Added `console.log` statements to `parseUrlToUri` to trace the URL transformation process and aid in debugging. --- src/devtoolsPanel.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/devtoolsPanel.ts b/src/devtoolsPanel.ts index 96a1322d..cef69295 100644 --- a/src/devtoolsPanel.ts +++ b/src/devtoolsPanel.ts @@ -399,7 +399,7 @@ export class DevToolsPanel { await ErrorReporter.showErrorDialog({ errorCode: ErrorCodes.Error, title: 'Error while opening file in editor.', - message: `Could not open document. No workspace mapping was found for '${url}'.`, + message: `Could not open document. No workspace mapping was found for '${url}'. Please configure the 'pathMapping' in your 'launch.json' file.`, }); } } @@ -491,6 +491,9 @@ export class DevToolsPanel { } private async parseUrlToUri(url: string): Promise { + if (vscode.debug.activeDebugSession) { + console.log(`Original URL: ${url}`); + } // Convert the devtools url into a local one let sourcePath = url; let appendedEntryPoint = false; @@ -513,6 +516,10 @@ export class DevToolsPanel { sourcePath = applyPathMapping(sourcePath, this.config.sourceMapPathOverrides); } + if (vscode.debug.activeDebugSession) { + console.log(`Source path after entrypoint and source map path overrides: ${sourcePath}`); + } + // Convert the local url to a workspace path const transformer = new debugCore.UrlPathTransformer(); void transformer.launch({ pathMapping: this.config.pathMapping }); @@ -522,6 +529,10 @@ export class DevToolsPanel { const localSource = { path: sourcePath, origin: 'invalid-origin://' }; await transformer.fixSource(localSource); + if (vscode.debug.activeDebugSession) { + console.log(`Local source path after transformation: ${localSource.path}`); + } + // per documentation if the file was correctly resolved origin will be cleared. // https://github.com/Microsoft/vscode-chrome-debug-core/blob/main/src/transformers/urlPathTransformer.ts if (!localSource.origin) { @@ -535,7 +546,7 @@ export class DevToolsPanel { await ErrorReporter.showInformationDialog({ errorCode: ErrorCodes.Error, title: 'Unable to open file in editor.', - message: `${sourcePath} does not map to a local file.${appendedEntryPoint ? entryPointErrorMessage : ''}`, + message: `Could not open '${sourcePath}' in the editor. Make sure that the file is part of the workspace and that 'pathMapping' is configured correctly in your 'launch.json'.${appendedEntryPoint ? entryPointErrorMessage : ''}`, }); }