|
3 | 3 | *--------------------------------------------------------*/
|
4 | 4 |
|
5 | 5 | import cp = require("child_process");
|
| 6 | +import crypto = require("crypto"); |
6 | 7 | import fs = require("fs");
|
7 | 8 | import net = require("net");
|
8 | 9 | import os = require("os");
|
@@ -165,19 +166,23 @@ export class SessionManager implements Middleware {
|
165 | 166 | }
|
166 | 167 | }
|
167 | 168 |
|
| 169 | + // Generate a random id for the named pipes in case they have multiple instances of PSES running |
| 170 | + const id = crypto.randomBytes(10).toString("hex"); |
168 | 171 | this.editorServicesArgs =
|
169 |
| - "-HostName 'Visual Studio Code Host' " + |
170 |
| - "-HostProfileId 'Microsoft.VSCode' " + |
171 |
| - "-HostVersion '" + this.hostVersion + "' " + |
172 |
| - "-AdditionalModules @('PowerShellEditorServices.VSCode') " + |
173 |
| - "-BundledModulesPath '" + this.bundledModulesPath + "' " + |
174 |
| - "-EnableConsoleRepl "; |
| 172 | + `-HostName 'Visual Studio Code Host' ` + |
| 173 | + `-HostProfileId 'Microsoft.VSCode' ` + |
| 174 | + `-HostVersion '${this.hostVersion}'` + |
| 175 | + `-AdditionalModules @('PowerShellEditorServices.VSCode') ` + |
| 176 | + `-BundledModulesPath '${this.bundledModulesPath}'` + |
| 177 | + `-EnableConsoleRepl ` + |
| 178 | + `-LanguageServicePipeName LanguageService_${id}.pipe ` + |
| 179 | + `-DebugServicePipeName DebugService_${id}.pipe `; |
175 | 180 |
|
176 | 181 | if (this.sessionSettings.developer.editorServicesWaitForDebugger) {
|
177 | 182 | this.editorServicesArgs += "-WaitForDebugger ";
|
178 | 183 | }
|
179 | 184 | if (this.sessionSettings.developer.editorServicesLogLevel) {
|
180 |
| - this.editorServicesArgs += "-LogLevel '" + this.sessionSettings.developer.editorServicesLogLevel + "' "; |
| 185 | + this.editorServicesArgs += `-LogLevel '${this.sessionSettings.developer.editorServicesLogLevel}' `; |
181 | 186 | }
|
182 | 187 |
|
183 | 188 | this.startPowerShell();
|
@@ -531,18 +536,18 @@ export class SessionManager implements Middleware {
|
531 | 536 |
|
532 | 537 | private startLanguageClient(sessionDetails: utils.IEditorServicesSessionDetails) {
|
533 | 538 |
|
534 |
| - const port = sessionDetails.languageServicePort; |
| 539 | + const pipeName = sessionDetails.languageServicePipeName; |
535 | 540 |
|
536 | 541 | // Log the session details object
|
537 | 542 | this.log.write(JSON.stringify(sessionDetails));
|
538 | 543 |
|
539 | 544 | try {
|
540 |
| - this.log.write("Connecting to language service on port " + port + "..."); |
| 545 | + this.log.write("Connecting to language service on pipe " + pipeName + "..."); |
541 | 546 |
|
542 | 547 | const connectFunc = () => {
|
543 | 548 | return new Promise<StreamInfo>(
|
544 | 549 | (resolve, reject) => {
|
545 |
| - const socket = net.connect(port); |
| 550 | + const socket = net.connect(utils.getPipePath(pipeName)); |
546 | 551 | socket.on(
|
547 | 552 | "connect",
|
548 | 553 | () => {
|
|
0 commit comments