@@ -63,7 +63,6 @@ export class DebugCommands {
6363 context . subscriptions . push ( vs . commands . registerCommand ( "flutter.inspectWidget" , ( ) => this . flutterExtensions . toggle ( FlutterServiceExtension . InspectorSelectMode , true , true ) ) ) ;
6464 context . subscriptions . push ( vs . commands . registerCommand ( "flutter.cancelInspectWidget" , ( ) => this . flutterExtensions . toggle ( FlutterServiceExtension . InspectorSelectMode , false , false ) ) ) ;
6565
66- // Open Observatory.
6766 context . subscriptions . push ( vs . commands . registerCommand ( "dart.openObservatory" , async ( ) => {
6867 if ( ! debugSessions . length )
6968 return ;
@@ -187,13 +186,45 @@ export class DebugCommands {
187186 type : "dart" ,
188187 } ) ;
189188 } ) ) ;
190- context . subscriptions . push ( vs . commands . registerCommand ( "flutter.attach " , ( ) => {
189+ context . subscriptions . push ( vs . commands . registerCommand ( "flutter.attachProcess " , ( ) => {
191190 vs . debug . startDebugging ( undefined , {
192191 name : "Flutter: Attach to Process" ,
192+ observatoryUri : "${command:dart.promptForVmService}" ,
193+ request : "attach" ,
194+ type : "dart" ,
195+ } ) ;
196+ } ) ) ;
197+ context . subscriptions . push ( vs . commands . registerCommand ( "flutter.attach" , ( ) => {
198+ vs . debug . startDebugging ( undefined , {
199+ name : "Flutter: Attach to Device" ,
193200 request : "attach" ,
194201 type : "dart" ,
195202 } ) ;
196203 } ) ) ;
204+ context . subscriptions . push ( vs . commands . registerCommand ( "dart.promptForVmService" , async ( defaultValueOrConfig : string | vs . DebugConfiguration | undefined ) : Promise < string | undefined > => {
205+ const defaultValue = typeof defaultValueOrConfig === "string" ? defaultValueOrConfig : undefined ;
206+ return vs . window . showInputBox ( {
207+ ignoreFocusOut : true , // Don't close the window if the user tabs away to get the uri
208+ placeHolder : "Paste an Observatory URI" ,
209+ prompt : "Enter Observatory URI" ,
210+ validateInput : ( input ) => {
211+ if ( ! input )
212+ return ;
213+
214+ input = input . trim ( ) ;
215+
216+ if ( Number . isInteger ( parseFloat ( input ) ) )
217+ return ;
218+
219+ // Uri.parse doesn't seem to work as expected, so do our own basic validation
220+ // https://github.com/Microsoft/vscode/issues/49818
221+
222+ if ( ! input . startsWith ( "http://" ) && ! input . startsWith ( "https://" ) )
223+ return "Please enter a valid Observatory URI" ;
224+ } ,
225+ value : defaultValue ,
226+ } ) ;
227+ } ) ) ;
197228 }
198229
199230 public handleDebugSessionStart ( s : vs . DebugSession ) : void {
0 commit comments