From 0ea981f5a96fc194f23ec4343f8222ef4a805ca9 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Mon, 26 Feb 2024 10:54:42 -0800 Subject: [PATCH] Fix the null-reference exception when running `Debug-Job` on a thread job --- PSReadLine/Prediction.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); } }