@@ -27,6 +27,7 @@ import cp = require('child_process');
2727import ipc = require( 'ipc' ) ;
2828
2929export const PLUGIN_LOG_BROADCAST_CHANNEL = 'vscode:pluginLog' ;
30+ export const PLUGIN_ATTACH_BROADCAST_CHANNEL = 'vscode:pluginAttach' ;
3031
3132// Enable to see detailed message communication between window and plugin host
3233const logPluginHostCommunication = false ;
@@ -126,14 +127,24 @@ class PluginHostProcessManager {
126127 this . initializePluginHostProcess = new TPromise < cp . ChildProcess > ( ( c , e ) => {
127128
128129 // Resolve additional execution args (e.g. debug)
129- return this . resolveExecArgv ( config , ( execArgv ) => {
130- if ( execArgv ) {
131- opts . execArgv = execArgv ;
130+ return this . resolveDebugPort ( config , ( port ) => {
131+ if ( port ) {
132+ opts . execArgv = [ '--nolazy' , ( config . env . debugBrkPluginHost ? '--debug-brk=' : '--debug=' ) + port ] ;
132133 }
133134
134135 // Run Plugin Host as fork of current process
135136 this . pluginHostProcessHandle = cp . fork ( uri . parse ( require . toUrl ( 'bootstrap' ) ) . fsPath , [ '--type=pluginHost' ] , opts ) ;
136137
138+ // Notify debugger that we are ready to attach to the process if we run a development plugin
139+ if ( config . env . pluginDevelopmentPath && port ) {
140+ this . windowService . broadcast ( {
141+ channel : PLUGIN_ATTACH_BROADCAST_CHANNEL ,
142+ payload : {
143+ port : port
144+ }
145+ } ) ;
146+ }
147+
137148 // Messages from Plugin host
138149 this . pluginHostProcessHandle . on ( 'message' , ( msg ) => {
139150
@@ -251,7 +262,7 @@ class PluginHostProcessManager {
251262 } , ( ) => this . terminate ( ) ) ;
252263 }
253264
254- private resolveExecArgv ( config : IConfiguration , clb : ( execArgv : any ) => void ) : void {
265+ private resolveDebugPort ( config : IConfiguration , clb : ( port : number ) => void ) : void {
255266
256267 // Check for a free debugging port
257268 if ( typeof config . env . debugPluginHostPort === 'number' ) {
@@ -272,7 +283,7 @@ class PluginHostProcessManager {
272283 console . info ( '%c[Plugin Host] %cdebugger listening on port ' + port , 'color: blue' , 'color: black' ) ;
273284 }
274285
275- return clb ( [ '--nolazy' , ( config . env . debugBrkPluginHost ? '--debug-brk=' : '--debug=' ) + port ] ) ;
286+ return clb ( port ) ;
276287 } ) ;
277288 }
278289
0 commit comments