@@ -63,15 +63,18 @@ export class SessionManager {
6363
6464 private hostVersion : string ;
6565 private isWindowsOS : boolean ;
66+ private sessionFilePath : string ;
6667 private sessionStatus : SessionStatus ;
6768 private focusConsoleOnExecute : boolean ;
69+ private extensionFeatures : IFeature [ ] = [ ] ;
6870 private statusBarItem : vscode . StatusBarItem ;
6971 private sessionConfiguration : SessionConfiguration ;
7072 private versionDetails : PowerShellVersionDetails ;
7173 private registeredCommands : vscode . Disposable [ ] = [ ] ;
7274 private consoleTerminal : vscode . Terminal = undefined ;
7375 private languageServerClient : LanguageClient = undefined ;
7476 private sessionSettings : Settings . ISettings = undefined ;
77+ private sessionDetails : utils . EditorServicesSessionDetails ;
7578
7679 // When in development mode, VS Code's session ID is a fake
7780 // value of "someValue.machineId". Use that to detect dev
@@ -81,8 +84,7 @@ export class SessionManager {
8184
8285 constructor (
8386 private requiredEditorServicesVersion : string ,
84- private log : Logger ,
85- private extensionFeatures : IFeature [ ] = [ ] ) {
87+ private log : Logger ) {
8688
8789 this . isWindowsOS = os . platform ( ) == "win32" ;
8890
@@ -107,6 +109,10 @@ export class SessionManager {
107109 this . registerCommands ( ) ;
108110 }
109111
112+ public setExtensionFeatures ( extensionFeatures : IFeature [ ] ) {
113+ this . extensionFeatures = extensionFeatures ;
114+ }
115+
110116 public start ( sessionConfig : SessionConfiguration = { type : SessionType . UseDefault } ) {
111117 this . sessionSettings = Settings . load ( utils . PowerShellLanguageId ) ;
112118 this . log . startNewLog ( this . sessionSettings . developer . editorServicesLogLevel ) ;
@@ -115,6 +121,10 @@ export class SessionManager {
115121
116122 this . createStatusBarItem ( ) ;
117123
124+ this . sessionFilePath =
125+ utils . getSessionFilePath (
126+ Math . floor ( 100000 + Math . random ( ) * 900000 ) ) ;
127+
118128 this . sessionConfiguration = this . resolveSessionConfiguration ( sessionConfig ) ;
119129
120130 if ( this . sessionConfiguration . type === SessionType . UsePath ||
@@ -191,7 +201,7 @@ export class SessionManager {
191201 }
192202
193203 // Clean up the session file
194- utils . deleteSessionFile ( ) ;
204+ utils . deleteSessionFile ( this . sessionFilePath ) ;
195205
196206 // Kill the PowerShell process we spawned via the console
197207 if ( this . consoleTerminal !== undefined ) {
@@ -203,6 +213,10 @@ export class SessionManager {
203213 this . sessionStatus = SessionStatus . NotStarted ;
204214 }
205215
216+ public getSessionDetails ( ) : utils . EditorServicesSessionDetails {
217+ return this . sessionDetails ;
218+ }
219+
206220 public dispose ( ) : void {
207221 // Stop the current session
208222 this . stop ( ) ;
@@ -284,7 +298,7 @@ export class SessionManager {
284298
285299 startArgs +=
286300 `-LogPath '${ editorServicesLogPath } ' ` +
287- `-SessionDetailsPath '${ utils . getSessionFilePath ( ) } ' ` +
301+ `-SessionDetailsPath '${ this . sessionFilePath } ' ` +
288302 `-FeatureFlags @(${ featureFlags } )`
289303
290304 var powerShellArgs = [
@@ -316,11 +330,11 @@ export class SessionManager {
316330 powerShellExePath = batScriptPath ;
317331 }
318332
319- // Make sure no old session file exists
320- utils . deleteSessionFile ( ) ;
321-
322333 this . log . write ( `${ utils . getTimestampString ( ) } Language server starting...` ) ;
323334
335+ // Make sure no old session file exists
336+ utils . deleteSessionFile ( this . sessionFilePath ) ;
337+
324338 // Launch PowerShell in the integrated terminal
325339 this . consoleTerminal =
326340 vscode . window . createTerminal (
@@ -334,13 +348,16 @@ export class SessionManager {
334348
335349 // Start the language client
336350 utils . waitForSessionFile (
351+ this . sessionFilePath ,
337352 ( sessionDetails , error ) => {
353+ this . sessionDetails = sessionDetails ;
354+
338355 if ( sessionDetails ) {
339356 if ( sessionDetails . status === "started" ) {
340357 this . log . write ( `${ utils . getTimestampString ( ) } Language server started.` ) ;
341358
342- // Write out the session configuration file
343- utils . writeSessionFile ( sessionDetails ) ;
359+ // The session file is no longer needed
360+ utils . deleteSessionFile ( this . sessionFilePath ) ;
344361
345362 // Start the language service client
346363 this . startLanguageClient ( sessionDetails ) ;
@@ -422,6 +439,9 @@ export class SessionManager {
422439
423440 var port = sessionDetails . languageServicePort ;
424441
442+ // Log the session details object
443+ this . log . write ( JSON . stringify ( sessionDetails ) ) ;
444+
425445 try
426446 {
427447 this . log . write ( "Connecting to language service on port " + port + "..." + os . EOL ) ;
@@ -433,9 +453,6 @@ export class SessionManager {
433453 socket . on (
434454 'connect' ,
435455 ( ) => {
436- // Write out the session configuration file
437- utils . writeSessionFile ( sessionDetails ) ;
438-
439456 this . log . write ( "Language service connected." ) ;
440457 resolve ( { writer : socket , reader : socket } )
441458 } ) ;
0 commit comments