diff --git a/PSReadLine/Prediction.cs b/PSReadLine/Prediction.cs index 7ece2ed1b..bd1448b9a 100644 --- a/PSReadLine/Prediction.cs +++ b/PSReadLine/Prediction.cs @@ -50,7 +50,9 @@ private static void UpdatePredictionClient(Runspace runspace, EngineIntrinsics e if (s_pCurrentLocation is not null) { // Set the current location if it's a local Runspace. Otherwise, set it to null. - object path = runspace.RunspaceIsRemote ? null : engineIntrinsics.SessionState.Path.CurrentLocation; + object path = runspace is null || runspace.RunspaceIsRemote + ? null + : engineIntrinsics?.SessionState.Path.CurrentLocation; s_pCurrentLocation.SetValue(s_predictionClient, path); } }