From 0cb5b6d776374b0908d57fb8147151aad4b47ec1 Mon Sep 17 00:00:00 2001 From: Patrick Meinecke Date: Wed, 28 Dec 2022 13:51:58 -0500 Subject: [PATCH] Use an empty array instead of `null` Fixes #1959 The code on the client expects DefaultChoices to never be `null`. If you send `null`, it tries to access the property `length` on what would be an array. --- src/PowerShellEditorServices/Extensions/Api/EditorUIService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PowerShellEditorServices/Extensions/Api/EditorUIService.cs b/src/PowerShellEditorServices/Extensions/Api/EditorUIService.cs index 4b50e6e41..a62131d2e 100644 --- a/src/PowerShellEditorServices/Extensions/Api/EditorUIService.cs +++ b/src/PowerShellEditorServices/Extensions/Api/EditorUIService.cs @@ -168,7 +168,7 @@ public async Task PromptSelectionAsync(string message, IReadOnlyList -1 ? new[] { defaultChoiceIndex } : null, + DefaultChoices = defaultChoiceIndex > -1 ? new[] { defaultChoiceIndex } : Array.Empty(), }) .Returning(CancellationToken.None) .ConfigureAwait(false);