@@ -23,9 +23,12 @@ import { Version } from "../utilities/version";
23
23
import { execFileStreamOutput } from "../utilities/utilities" ;
24
24
import configuration from "../configuration" ;
25
25
26
- export async function captureDiagnostics ( ctx : WorkspaceContext ) {
26
+ export async function captureDiagnostics (
27
+ ctx : WorkspaceContext ,
28
+ allowMinimalCapture : boolean = true
29
+ ) {
27
30
try {
28
- const captureMode = await captureDiagnosticsMode ( ctx ) ;
31
+ const captureMode = await captureDiagnosticsMode ( ctx , allowMinimalCapture ) ;
29
32
30
33
// dialog was cancelled
31
34
if ( ! captureMode ) {
@@ -58,16 +61,34 @@ export async function captureDiagnostics(ctx: WorkspaceContext) {
58
61
}
59
62
}
60
63
64
+ export async function promptForDiagnostics ( ctx : WorkspaceContext ) {
65
+ const ok = "OK" ;
66
+ const cancel = "Cancel" ;
67
+ const result = await vscode . window . showInformationMessage (
68
+ "SourceKit-LSP has been restored. Would you like to capture a diagnostic bundle to file an issue?" ,
69
+ ok ,
70
+ cancel
71
+ ) ;
72
+
73
+ if ( ! result || result === cancel ) {
74
+ return ;
75
+ }
76
+
77
+ return await captureDiagnostics ( ctx , false ) ;
78
+ }
79
+
61
80
async function captureDiagnosticsMode (
62
- ctx : WorkspaceContext
81
+ ctx : WorkspaceContext ,
82
+ allowMinimalCapture : boolean
63
83
) : Promise < "Minimal" | "Full" | undefined > {
64
84
if (
65
85
ctx . swiftVersion . isGreaterThanOrEqual ( new Version ( 6 , 0 , 0 ) ) ||
66
86
vscode . workspace . getConfiguration ( "sourcekit-lsp" ) . get < string > ( "trace.server" , "off" ) !==
67
87
"off"
68
88
) {
69
- const fullButton = "Capture Full Diagnostics" ;
89
+ const fullButton = allowMinimalCapture ? "Capture Full Diagnostics" : "Capture Diagnostics";
70
90
const minimalButton = "Capture Minimal Diagnostics" ;
91
+ const buttons = allowMinimalCapture ? [ fullButton , minimalButton ] : [ fullButton ] ;
71
92
const fullCaptureResult = await vscode . window . showInformationMessage (
72
93
`A Diagnostic Bundle collects information that helps the developers of the VS Code Swift extension diagnose and fix issues.
73
94
@@ -82,10 +103,11 @@ This information contains:
82
103
Please attach this bundle to GitHub issues.` ,
83
104
{
84
105
modal : true ,
85
- detail : `If you wish to omit potentially sensitive information choose "${ minimalButton } "` ,
106
+ detail : allowMinimalCapture
107
+ ? `If you wish to omit potentially sensitive information choose "${ minimalButton } "`
108
+ : undefined ,
86
109
} ,
87
- fullButton ,
88
- minimalButton
110
+ ...buttons
89
111
) ;
90
112
if ( ! fullCaptureResult ) {
91
113
return undefined ;
0 commit comments