@@ -16,8 +16,9 @@ import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
1616import { INotificationService } from 'vs/platform/notification/common/notification' ;
1717import { formatPII } from 'vs/workbench/parts/debug/common/debugUtils' ;
1818import { SocketDebugAdapter } from 'vs/workbench/parts/debug/node/debugAdapter' ;
19- import { DebugEvent , IRawSession , IDebugAdapter } from 'vs/workbench/parts/debug/common/debug' ;
19+ import { DebugEvent , IRawSession , IDebugAdapter , IConfig } from 'vs/workbench/parts/debug/common/debug' ;
2020import { CancellationToken , CancellationTokenSource } from 'vs/base/common/cancellation' ;
21+ import { equalsIgnoreCase } from 'vs/base/common/strings' ;
2122
2223export interface SessionExitedEvent extends DebugEvent {
2324 body : {
@@ -47,7 +48,8 @@ export class RawDebugSession implements IRawSession {
4748 private cancellationTokens : CancellationTokenSource [ ] ;
4849 private _capabilities : DebugProtocol . Capabilities ;
4950 private allThreadsContinued : boolean ;
50- private isAttached : boolean ;
51+ private debugServerPort : number ;
52+ private isAttach : boolean ;
5153
5254 private readonly _onDidInitialize : Emitter < DebugProtocol . InitializedEvent > ;
5355 private readonly _onDidStop : Emitter < DebugProtocol . StoppedEvent > ;
@@ -64,7 +66,7 @@ export class RawDebugSession implements IRawSession {
6466
6567 constructor (
6668 private sessionId : string ,
67- private debugServerPort : number ,
69+ configuration : IConfig ,
6870 private _debugger : Debugger ,
6971 public customTelemetryService : ITelemetryService ,
7072 private root : IWorkspaceFolder ,
@@ -76,6 +78,8 @@ export class RawDebugSession implements IRawSession {
7678 this . readyForBreakpoints = false ;
7779 this . allThreadsContinued = true ;
7880 this . cancellationTokens = [ ] ;
81+ this . debugServerPort = configuration . debugServer ;
82+ this . isAttach = configuration . request === 'attach' || equalsIgnoreCase ( configuration . type , 'extensionHost' ) ;
7983
8084 this . _onDidInitialize = new Emitter < DebugProtocol . InitializedEvent > ( ) ;
8185 this . _onDidStop = new Emitter < DebugProtocol . StoppedEvent > ( ) ;
@@ -288,7 +292,6 @@ export class RawDebugSession implements IRawSession {
288292 }
289293
290294 public attach ( args : DebugProtocol . AttachRequestArguments ) : TPromise < DebugProtocol . AttachResponse > {
291- this . isAttached = true ;
292295 return this . send ( 'attach' , args ) . then ( response => this . readCapabilities ( response ) ) ;
293296 }
294297
@@ -347,7 +350,7 @@ export class RawDebugSession implements IRawSession {
347350 }
348351
349352 public terminate ( restart = false ) : TPromise < DebugProtocol . TerminateResponse > {
350- if ( this . capabilities . supportsTerminateRequest && ! this . terminated && ! this . isAttached ) {
353+ if ( this . capabilities . supportsTerminateRequest && ! this . terminated && ! this . isAttach ) {
351354 this . terminated = true ;
352355 return this . send ( 'terminate' , { restart } ) ;
353356 }
0 commit comments