@@ -148,30 +148,26 @@ export class WebKitDebugAdapter implements IDebugAdapter {
148
148
149
149
androidProject . on ( 'TNS.outputMessage' , ( message , level ) => thisAdapter . onTnsOutputMessage . apply ( thisAdapter , [ message , level ] ) ) ;
150
150
151
- let port : number ;
152
151
this . onTnsOutputMessage ( "Getting debug port" ) ;
153
152
let androidConnection : AndroidDebugConnection = null ;
154
- return androidProject . getDebugPort ( args )
155
- . then ( debugPort => {
156
- port = debugPort ;
157
- if ( ! thisAdapter . _webKitConnection ) {
158
- return androidProject . createConnection ( ) . then ( connection => {
159
- androidConnection = connection ;
160
- this . setConnection ( connection , args ) ;
161
- return Promise . resolve < void > ( ) ;
162
- } ) ;
163
- }
164
153
165
- return Promise . resolve < void > ( ) ;
166
- } )
167
- . then ( ( ) => {
168
- this . onTnsOutputMessage ( "Preparing for debug" ) ;
169
- return androidProject . debug ( args ) ;
170
- } )
171
- . then ( ( ) => {
172
- this . onTnsOutputMessage ( "Attaching to debug application" ) ;
173
- return androidConnection . attach ( port , 'localhost' ) ;
174
- } ) ;
154
+ let runDebugCommand : Promise < any > = ( args . request == 'launch' ) ? androidProject . debug ( args ) : Promise . resolve ( ) ;
155
+
156
+ return runDebugCommand . then ( _ => {
157
+ let port : number ;
158
+ return androidProject . getDebugPort ( args ) . then ( debugPort => {
159
+ port = debugPort ;
160
+ if ( ! thisAdapter . _webKitConnection ) {
161
+ return androidProject . createConnection ( ) . then ( connection => {
162
+ androidConnection = connection ;
163
+ this . setConnection ( connection , args ) ;
164
+ } ) ;
165
+ }
166
+ } ) . then ( ( ) => {
167
+ this . onTnsOutputMessage ( "Attaching to debug application" ) ;
168
+ return androidConnection . attach ( port , 'localhost' ) ;
169
+ } ) ;
170
+ } ) ;
175
171
}
176
172
177
173
private setConnection ( connection : ns . INSDebugConnection , args : IAttachRequestArgs | ILaunchRequestArgs ) : ns . INSDebugConnection {
0 commit comments