MCPcopy
hub / github.com/PowerShell/vscode-powershell / start

Method start

src/session.ts:190–311  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

188 // The `exeNameOverride` is used by `restartSession` to override ANY other setting.
189 // We've made this function idempotent, so it can used to ensure the session has started.
190 public async start(): Promise<void> {
191 switch (this.sessionStatus) {
192 case SessionStatus.NotStarted:
193 // Go ahead and start.
194 break;
195 case SessionStatus.Starting:
196 // A simple lock because this function isn't re-entrant.
197 this.logger.writeWarning("Re-entered 'start' so waiting...");
198 await this.waitWhileStarting();
199 return;
200 case SessionStatus.Running:
201 // We're started, just return.
202 this.logger.writeDebug("Already started.");
203 return;
204 case SessionStatus.Busy:
205 // We're started but busy so notify and return.
206 // TODO: Make a proper notification for this and when IntelliSense is blocked.
207 this.logger.write(
208 "The Extension Terminal is currently busy, please wait for your task to finish!",
209 );
210 return;
211 case SessionStatus.Stopping:
212 // Wait until done stopping, then start.
213 this.logger.writeDebug("Still stopping.");
214 await this.waitWhileStopping();
215 break;
216 case SessionStatus.Failed:
217 // Try to start again.
218 this.logger.writeDebug("Previously failed, starting again.");
219 break;
220 }
221
222 // This status needs to be set immediately so the above check works
223 this.setSessionStatus("Starting...", SessionStatus.Starting);
224
225 this.startCancellationTokenSource =
226 new vscode.CancellationTokenSource();
227 const cancellationToken = this.startCancellationTokenSource.token;
228
229 // Create a folder for the session files.
230 await vscode.workspace.fs.createDirectory(this.sessionsFolder);
231
232 // Migrate things.
233 await this.migrateWhitespaceAroundPipeSetting();
234
235 // Update non-PowerShell settings.
236 this.shellIntegrationEnabled =
237 vscode.workspace
238 .getConfiguration("terminal.integrated.shellIntegration")
239 .get<boolean>("enabled") ?? false;
240
241 // Find the PowerShell executable to use for the server.
242 this.PowerShellExeDetails = await this.findPowerShell();
243
244 if (this.PowerShellExeDetails === undefined) {
245 const message =
246 "Unable to find PowerShell!" +
247 " Do you have it installed?" +

Callers 5

restartSessionMethod · 0.95
activateFunction · 0.45
startLanguageClientMethod · 0.45

Calls 15

waitWhileStartingMethod · 0.95
waitWhileStoppingMethod · 0.95
setSessionStatusMethod · 0.95
findPowerShellMethod · 0.95
refreshSessionStatusMethod · 0.95
sessionStartedMethod · 0.95
handleFailedProcessMethod · 0.95
startLanguageClientMethod · 0.95
getVersionDetailsMethod · 0.95

Tested by

no test coverage detected