From 368bc70af7783ef73e051d52a620b86447db9a84 Mon Sep 17 00:00:00 2001 From: Ahmed Date: Wed, 20 May 2026 18:10:55 +0300 Subject: [PATCH 1/2] Fix exit code handling in GetCompletions method to ensure correct result assignment --- src/System.CommandLine.Suggest/SuggestionStore.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/System.CommandLine.Suggest/SuggestionStore.cs b/src/System.CommandLine.Suggest/SuggestionStore.cs index ac93972eb1..00d95351e8 100644 --- a/src/System.CommandLine.Suggest/SuggestionStore.cs +++ b/src/System.CommandLine.Suggest/SuggestionStore.cs @@ -44,8 +44,12 @@ public string GetCompletions(string exeFileName, string suggestionTargetArgument Task readToEndTask = process.StandardOutput.ReadToEndAsync(); - if (readToEndTask.Wait(timeout)) + if (readToEndTask.Wait(timeout)) { + if(process.ExitCode == 0) + { + result = readToEndTask.Result; + } result = readToEndTask.Result; } else From 73057912e3421134ece3ed36ca44a89b95490aa1 Mon Sep 17 00:00:00 2001 From: Ahmed Date: Wed, 20 May 2026 18:41:08 +0300 Subject: [PATCH 2/2] Fix exit code handling using WaitForExit and remove duplicate assignment --- src/System.CommandLine.Suggest/SuggestionStore.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/System.CommandLine.Suggest/SuggestionStore.cs b/src/System.CommandLine.Suggest/SuggestionStore.cs index 00d95351e8..f30637d3ad 100644 --- a/src/System.CommandLine.Suggest/SuggestionStore.cs +++ b/src/System.CommandLine.Suggest/SuggestionStore.cs @@ -44,13 +44,13 @@ public string GetCompletions(string exeFileName, string suggestionTargetArgument Task readToEndTask = process.StandardOutput.ReadToEndAsync(); - if (readToEndTask.Wait(timeout)) + if (process.WaitForExit((int)timeout.TotalMilliseconds)) { if(process.ExitCode == 0) { result = readToEndTask.Result; } - result = readToEndTask.Result; + } else {