Skip to content

Commit 8612b46

Browse files
committed
Run SetInitialWorkingDirectoryAsync before LoadProfiles
So that if a user runs `Set-Location` in their profile, it's not later overridden.
1 parent 993a54c commit 8612b46

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,13 @@ public async Task<bool> TryStartAsync(HostStartOptions startOptions, Cancellatio
301301

302302
_pipelineThread.Start();
303303

304+
if (startOptions.InitialWorkingDirectory is not null)
305+
{
306+
_logger.LogDebug($"Setting InitialWorkingDirectory to {startOptions.InitialWorkingDirectory}...");
307+
await SetInitialWorkingDirectoryAsync(startOptions.InitialWorkingDirectory, cancellationToken).ConfigureAwait(false);
308+
_logger.LogDebug("InitialWorkingDirectory set!");
309+
}
310+
304311
if (startOptions.LoadProfiles)
305312
{
306313
_logger.LogDebug("Loading profiles...");
@@ -320,13 +327,6 @@ public async Task<bool> TryStartAsync(HostStartOptions startOptions, Cancellatio
320327
_logger.LogDebug("Shell integration not enabled!");
321328
}
322329

323-
if (startOptions.InitialWorkingDirectory is not null)
324-
{
325-
_logger.LogDebug($"Setting InitialWorkingDirectory to {startOptions.InitialWorkingDirectory}...");
326-
await SetInitialWorkingDirectoryAsync(startOptions.InitialWorkingDirectory, cancellationToken).ConfigureAwait(false);
327-
_logger.LogDebug("InitialWorkingDirectory set!");
328-
}
329-
330330
await _started.Task.ConfigureAwait(false);
331331
return true;
332332
}

0 commit comments

Comments
 (0)