@@ -139,20 +139,52 @@ export class DebugCommands implements IAmDisposable {
139
139
}
140
140
} ) ) ;
141
141
this . disposables . push ( vs . commands . registerCommand ( "dart.copyVmServiceUri" , async ( ) => {
142
- const session = await this . getDebugSession ( ) ;
143
- if ( ! session ) {
144
- await vs . window . showInformationMessage ( "No Dart/Flutter debug session available" ) ;
145
- return ;
142
+ const options : Array < vs . QuickPickItem & { session : DartDebugSessionInformation , vmServiceUri : string } > = [ ] ;
143
+
144
+ function addOption ( s : DartDebugSessionInformation , vmServiceUri : string , vmServiceKindDescription : string | undefined ) {
145
+ const description = [
146
+ s . session . workspaceFolder ?. name ,
147
+ s . session . configuration . deviceName ,
148
+ `Started ${ s . sessionStart . toLocaleTimeString ( ) } ` ,
149
+ ] . filter ( ( s ) => s ) . join ( ", " ) ;
150
+ options . push (
151
+ {
152
+ // TODO: add both vm service uri and description here somewhere
153
+ description,
154
+ detail : vmServiceKindDescription ? `${ vmServiceUri } (${ vmServiceKindDescription } )` : vmServiceUri ,
155
+ label : s . session . name ,
156
+ session : s ,
157
+ vmServiceUri,
158
+ }
159
+ ) ;
146
160
}
147
- const vmUri = session ?. vmServiceUri ;
148
- if ( ! vmUri ) {
149
- if ( session ?. hasStarted )
150
- await vs . window . showInformationMessage ( "This debug session does not have a VM Service" ) ;
151
- else
152
- await vs . window . showInformationMessage ( "This debug session is not ready yet" ) ;
161
+
162
+ for ( const debugSession of debugSessions ) {
163
+ const vmServiceUri = debugSession . vmServiceUri ;
164
+ let exposedVmServiceUri = debugSession . clientVmServiceUri ?? ( vmServiceUri ? await envUtils . exposeUrl ( vmServiceUri ) : undefined ) ;
165
+ if ( exposedVmServiceUri === vmServiceUri )
166
+ exposedVmServiceUri = undefined ;
167
+
168
+ if ( vmServiceUri )
169
+ addOption ( debugSession , vmServiceUri , exposedVmServiceUri ? "Local URI on the remote machine" : undefined ) ;
170
+ if ( exposedVmServiceUri )
171
+ addOption ( debugSession , exposedVmServiceUri , "The URI exposed to the client" ) ;
172
+ }
173
+
174
+ if ( options . length === 0 ) {
175
+ await vs . window . showInformationMessage (
176
+ debugSessions . length === 0
177
+ ? "No Dart/Flutter debug session available"
178
+ : "No running Dart/Flutter debug sessions have VM Service connections available"
179
+ ) ;
153
180
return ;
154
181
}
155
- await vs . env . clipboard . writeText ( vmUri . toString ( ) ) ;
182
+
183
+ const selectedOption = options . length === 1 ? options [ 0 ] : await vs . window . showQuickPick ( options , { placeHolder : "Which debug session / VM Service URI?" } ) ;
184
+ if ( ! selectedOption )
185
+ return ;
186
+
187
+ await vs . env . clipboard . writeText ( selectedOption . vmServiceUri ) ;
156
188
} ) ) ;
157
189
this . disposables . push ( vs . commands . registerCommand ( "dart.openDevTools.external" , ( ) => vs . commands . executeCommand ( "dart.openDevTools" , { commandSource : CommandSource . commandPalette , location : "external" as DevToolsLocation } ) ) ) ;
158
190
this . disposables . push ( vs . commands . registerCommand ( "_dart.openDevTools.touchBar" , ( ) => vs . commands . executeCommand ( "dart.openDevTools" , { commandSource : CommandSource . touchbar } ) ) ) ;
0 commit comments