Skip to content

Commit 8b27d86

Browse files
committed
Remove writeSessionFile as only the server writes it
No idea why we were writing it as the client. Maybe I've totally misunderstood, but everything works as expected without this (and moreover, we delete any existing session file and then wait for it, after passing the path to the server).
1 parent e4a5878 commit 8b27d86

File tree

2 files changed

+6
-21
lines changed

2 files changed

+6
-21
lines changed

src/features/DebugSession.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,9 @@ export class DebugSessionFeature extends LanguageClientConsumer
309309
// Create or show the interactive console
310310
vscode.commands.executeCommand("PowerShell.ShowSessionConsole", true);
311311

312-
const sessionFilePath = this.sessionManager.getNewSessionFilePath();
313-
314312
if (config.createTemporaryIntegratedConsole) {
315-
this.tempDebugProcess = this.sessionManager.createDebugSessionProcess(sessionFilePath, settings);
313+
this.tempDebugProcess = this.sessionManager.createDebugSessionProcess(settings);
316314
this.tempSessionDetails = await this.tempDebugProcess.start(`DebugSession-${this.sessionCount++}`);
317-
await this.sessionManager.writeSessionFile(sessionFilePath, this.tempSessionDetails);
318-
} else {
319-
await this.sessionManager.writeSessionFile(sessionFilePath, this.sessionManager.getSessionDetails());
320315
}
321316

322317
return config;

src/session.ts

+5-15
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,13 @@ export class SessionManager implements Middleware {
8585
version: string,
8686
private telemetryReporter: TelemetryReporter) {
8787

88+
// Create a folder for the session files.
8889
if (extensionContext.storageUri !== undefined) {
8990
this.sessionsFolder = vscode.Uri.joinPath(extensionContext.storageUri, "sessions");
9091
} else {
9192
this.sessionsFolder = vscode.Uri.file(path.resolve(__dirname, "../sessions"));
9293
}
94+
vscode.workspace.fs.createDirectory(this.sessionsFolder);
9395

9496
this.platformDetails = getPlatformDetails();
9597

@@ -285,14 +287,6 @@ export class SessionManager implements Middleware {
285287
return vscode.Uri.joinPath(this.sessionsFolder, "PSES-VSCode-" + process.env.VSCODE_PID + "-" + uniqueId + ".json");
286288
}
287289

288-
public async writeSessionFile(sessionFilePath: vscode.Uri, sessionDetails: IEditorServicesSessionDetails) {
289-
await vscode.workspace.fs.createDirectory(this.sessionsFolder);
290-
291-
const writeStream = fs.createWriteStream(sessionFilePath.fsPath);
292-
writeStream.write(JSON.stringify(sessionDetails));
293-
writeStream.close();
294-
}
295-
296290
public static readSessionFile(sessionFilePath: vscode.Uri): IEditorServicesSessionDetails {
297291
// TODO: Use vscode.workspace.fs.readFile instead of fs.readFileSync.
298292
const fileContents = fs.readFileSync(sessionFilePath.fsPath, "utf-8");
@@ -307,9 +301,7 @@ export class SessionManager implements Middleware {
307301
}
308302
}
309303

310-
public createDebugSessionProcess(
311-
sessionPath: vscode.Uri,
312-
sessionSettings: Settings.ISettings): PowerShellProcess {
304+
public createDebugSessionProcess(sessionSettings: Settings.ISettings): PowerShellProcess {
313305

314306
// NOTE: We only support one temporary integrated console at a time. To
315307
// support more, we need to track each separately, and tie the session
@@ -327,7 +319,7 @@ export class SessionManager implements Middleware {
327319
"[TEMP] PowerShell Integrated Console",
328320
this.log,
329321
this.editorServicesArgs + "-DebugServiceOnly ",
330-
sessionPath,
322+
this.getNewSessionFilePath(),
331323
sessionSettings);
332324

333325
// Similar to the regular integrated console, we need to send a key
@@ -493,16 +485,14 @@ export class SessionManager implements Middleware {
493485
private startPowerShell() {
494486
this.setSessionStatus("Starting...", SessionStatus.Initializing);
495487

496-
const sessionFilePath = this.getNewSessionFilePath();
497-
498488
this.languageServerProcess =
499489
new PowerShellProcess(
500490
this.PowerShellExeDetails.exePath,
501491
this.bundledModulesPath,
502492
"PowerShell Integrated Console",
503493
this.log,
504494
this.editorServicesArgs,
505-
sessionFilePath,
495+
this.getNewSessionFilePath(),
506496
this.sessionSettings);
507497

508498
this.languageServerProcess.onExited(

0 commit comments

Comments
 (0)