@@ -41,28 +41,49 @@ export async function captureDiagnostics(ctx: WorkspaceContext) {
41
41
42
42
ctx . outputChannel . log ( `Saved diagnostics to ${ diagnosticsDir } ` ) ;
43
43
44
- const showInFinderButton = " Show In Finder" ;
44
+ const showInFinderButton = ` Show In ${ showCommandType ( ) } ` ;
45
45
const copyPath = "Copy Path to Clipboard" ;
46
- const infoDialogButtons = [
47
- ...( process . platform === "darwin" ? [ showInFinderButton ] : [ ] ) ,
48
- copyPath ,
49
- ] ;
50
46
const result = await vscode . window . showInformationMessage (
51
47
`Saved diagnostic logs to ${ diagnosticsDir } ` ,
52
- ...infoDialogButtons
48
+ showInFinderButton ,
49
+ copyPath
53
50
) ;
54
51
if ( result === copyPath ) {
55
52
vscode . env . clipboard . writeText ( diagnosticsDir ) ;
56
53
} else if ( result === showInFinderButton ) {
57
- exec ( `open ${ diagnosticsDir } ` , error => {
58
- if ( error ) {
59
- vscode . window . showErrorMessage ( `Failed to open Finder: ${ error . message } ` ) ;
60
- return ;
54
+ exec ( showDirectoryCommand ( diagnosticsDir ) , error => {
55
+ // Opening the explorer on windows returns an exit code of 1 despite opening successfully.
56
+ if ( error && process . platform !== "win32" ) {
57
+ vscode . window . showErrorMessage (
58
+ `Failed to open ${ showCommandType ( ) } : ${ error . message } `
59
+ ) ;
61
60
}
62
61
} ) ;
63
62
}
64
63
} catch ( error ) {
65
- vscode . window . showErrorMessage ( `Unable to captrure diagnostics logs: ${ error } ` ) ;
64
+ vscode . window . showErrorMessage ( `Unable to capture diagnostic logs: ${ error } ` ) ;
65
+ }
66
+ }
67
+
68
+ function showDirectoryCommand ( dir : string ) : string {
69
+ switch ( process . platform ) {
70
+ case "win32" :
71
+ return `explorer ${ dir } ` ;
72
+ case "darwin" :
73
+ return `open ${ dir } ` ;
74
+ default :
75
+ return `xdg-open ${ dir } ` ;
76
+ }
77
+ }
78
+
79
+ function showCommandType ( ) : string {
80
+ switch ( process . platform ) {
81
+ case "win32" :
82
+ return "Explorer" ;
83
+ case "darwin" :
84
+ return "Finder" ;
85
+ default :
86
+ return "File Manager" ;
66
87
}
67
88
}
68
89
0 commit comments