Skip to content

Commit

Permalink
update html link fixing after Error reporter merge
Browse files Browse the repository at this point in the history
  • Loading branch information
bgoddar committed Aug 25, 2021
1 parent 5ff12b1 commit a740ae6
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions src/devtoolsPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,11 @@ export class DevToolsPanel {
sourcePath = addEntrypointIfNeeded(sourcePath, this.config.defaultEntrypoint);
appendedEntryPoint = true;
} catch (e) {
void vscode.window.showErrorMessage(`Could not open document. '${sourcePath}' is not a valid url.`);
await ErrorReporter.showInformationDialog({
errorCode: ErrorCodes.Error,
title: 'Unable to open file in editor.',
message: `'${sourcePath}' is not a valid url.`,
});
return;
}
}
Expand All @@ -337,33 +341,27 @@ export class DevToolsPanel {
const uri = vscode.Uri.file(localSource.path);
await this.openInEditor(uri, line, column);
} else {
// If failed to resolve origin, it's possible entrypoint needs to be updated.
// Space at beginning to allow insertion in message below
const entryPointErrorMessage = ` If ${sourcePath} is the entrypoint to your site, consider updating the 'Default Entrypoint' setting to map to your root html page. The current setting is '${this.config.defaultEntrypoint}'.`;
await ErrorReporter.showInformationDialog({
errorCode: ErrorCodes.Error,
title: 'Unable to open file in editor.',
message: `${sourcePath} does not map to a local file.`,
message: `${sourcePath} does not map to a local file.${appendedEntryPoint ? entryPointErrorMessage : ''}`,
});
}
}

private async openInEditor(uri:vscode.Uri, line: number, column: number){
try {
// Finally open the document if it exists
if (!uri.path?.startsWith('/http:')) {
const doc = await vscode.workspace.openTextDocument(uri);
void vscode.window.showTextDocument(
doc,
{
preserveFocus: true,
selection: new vscode.Range(line, column, line, column),
viewColumn: vscode.ViewColumn.One,
});
}else {
// workspace mapping failure and append attemtped to be set TODO fix
// let errorMessage = `Could not open document. No workspace mapping was found for '${url}'.`;
// if (appendedEntryPoint) {
// errorMessage += `If ${url} is the entrypoint to your site, consider updating the 'Default Entrypoint' setting to map to your root html page. The current setting is '${this.config.defaultEntrypoint}'.`;
// }
}
const doc = await vscode.workspace.openTextDocument(uri);
void vscode.window.showTextDocument(
doc,
{
preserveFocus: true,
selection: new vscode.Range(line, column, line, column),
viewColumn: vscode.ViewColumn.One,
});
} catch (e) {
await ErrorReporter.showErrorDialog({
errorCode: ErrorCodes.Error,
Expand Down

0 comments on commit a740ae6

Please sign in to comment.