Skip to content

Commit

Permalink
Fix path failure preventing trace from opening
Browse files Browse the repository at this point in the history
When doing some testing on an internal extension relying, I
noticed that we could no longer use the Open With TraceViewer
command on Windows due to an invalid path failing (worked on Linux).

I was able to trace the cause of this it to some code that uses
.path instead of .fsPath, which is intended for use with the
filesystem and scrubs out improper path values  (which is
what caused our error!)

This fixes a critical issue which prevents users from opening traces
in some cases.

Signed-off-by: Dylan Leclair <[email protected]>
  • Loading branch information
dleclairbb committed Oct 25, 2023
1 parent b2c8f77 commit cb950a6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions vscode-trace-extension/src/trace-explorer/trace-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export const fileHandler =
return;
}

const uri: string = resolvedTraceURI.path;
const uri: string = resolvedTraceURI.fsPath;
if (!uri) {
traceLogger.addLogMessage(
'Cannot open trace: could not retrieve path from URI for trace ' + resolvedTraceURI,
Expand Down Expand Up @@ -311,8 +311,8 @@ const isCtf = async (directory: string): Promise<boolean> => {
};

function getProgressBarTitle(traceUri: vscode.Uri | undefined): string {
if (!traceUri || !traceUri.path) {
if (!traceUri || !traceUri.fsPath) {
return 'undefined';
}
return traceUri.path.substring(traceUri.path.lastIndexOf('/') + 1);
return traceUri.fsPath.substring(traceUri.fsPath.lastIndexOf('/') + 1);
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class TraceViewerPanel {
private static async saveTraceCsv(csvData: string, defaultFileName: string) {
const saveDialogOptions = {
defaultUri: vscode.workspace.workspaceFolders
? vscode.Uri.file(vscode.workspace.workspaceFolders[0].uri.path + '/' + defaultFileName)
? vscode.Uri.file(vscode.workspace.workspaceFolders[0].uri.fsPath + '/' + defaultFileName)
: undefined,
saveLabel: 'Save as CSV',
filters: {
Expand Down

0 comments on commit cb950a6

Please sign in to comment.