Skip to content

Commit 170a265

Browse files
committed
Add null checks for Set/Load profile
1 parent 91810ec commit 170a265

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,12 @@ internal void DisableTranscribeOnly()
593593

594594
internal Task SetProfileVariableAsync(CancellationToken cancellationToken)
595595
{
596+
// If the CurrentUserCurrentHost profile is null then we cannot create the profile variable
597+
if (_hostInfo.ProfilePaths.CurrentUserCurrentHost is null)
598+
{
599+
return Task.CompletedTask;
600+
}
601+
596602
// NOTE: This is a special task run on startup!
597603
return ExecuteDelegateAsync(
598604
"SetProfileVariable",
@@ -603,6 +609,12 @@ internal Task SetProfileVariableAsync(CancellationToken cancellationToken)
603609

604610
internal Task LoadHostProfilesAsync(CancellationToken cancellationToken)
605611
{
612+
// If the CurrentUserCurrentHost profile is null then we cannot instantiate
613+
if (_hostInfo.ProfilePaths.CurrentUserCurrentHost is null)
614+
{
615+
return Task.CompletedTask;
616+
}
617+
606618
// NOTE: This is a special task run on startup!
607619
return ExecuteDelegateAsync(
608620
"LoadProfiles",

0 commit comments

Comments
 (0)