From 6d1d45c8ba127d08601787f5158c0905876825ec Mon Sep 17 00:00:00 2001 From: sugiiianaaa Date: Wed, 4 Mar 2026 21:41:41 +0800 Subject: [PATCH 1/2] add extended description on help, exit and clear command --- CSharpRepl/CSharpReplPromptCallbacks.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CSharpRepl/CSharpReplPromptCallbacks.cs b/CSharpRepl/CSharpReplPromptCallbacks.cs index 35e12c4..982ccc4 100644 --- a/CSharpRepl/CSharpReplPromptCallbacks.cs +++ b/CSharpRepl/CSharpReplPromptCallbacks.cs @@ -373,15 +373,18 @@ private static class ReplKeywordCompletionItems public static CompletionItem Help { get; } = new( ReadEvalPrintLoop.Keywords.HelpText, - displayText: helpFormattedString); + displayText: helpFormattedString, + getExtendedDescription: _ => Task.FromResult(new FormattedString("Show help and usage information for the C# REPL."))); public static CompletionItem Exit { get; } = new( ReadEvalPrintLoop.Keywords.ExitText, - displayText: exitFormattedString); + displayText: exitFormattedString, + getExtendedDescription: _ => Task.FromResult(new FormattedString("Exit the REPL. You can also press Ctrl + d."))); public static CompletionItem Clear { get; } = new( ReadEvalPrintLoop.Keywords.ClearText, - displayText: clearFormattedString); + displayText: clearFormattedString, + getExtendedDescription: _ => Task.FromResult(new FormattedString("Clear the terminal screen."))); public static IReadOnlyList AllItems = [Help, Exit, Clear]; } From 34563c5db23496f8ba8dcd23801f5adce73951a3 Mon Sep 17 00:00:00 2001 From: sugiiianaaa Date: Wed, 4 Mar 2026 22:06:26 +0800 Subject: [PATCH 2/2] add Complete_ReplKeywords_HaveDescriptions to test if replykeyword have intended description --- CSharpRepl.Tests/CompletionTests.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/CSharpRepl.Tests/CompletionTests.cs b/CSharpRepl.Tests/CompletionTests.cs index da350aa..ab78ad3 100644 --- a/CSharpRepl.Tests/CompletionTests.cs +++ b/CSharpRepl.Tests/CompletionTests.cs @@ -137,4 +137,17 @@ public async Task Complete_ReplKeywords(string source, string item) var completion = completions.SingleOrDefault(c => c.DisplayText == item); Assert.NotNull(completion); } -} \ No newline at end of file + + [Theory] + [InlineData("he", "help", "Show help")] + [InlineData("ex", "exit", "Exit the REPL")] + [InlineData("cl", "clear", "Clear the terminal")] + public async Task Complete_ReplKeywords_HaveDescription(string source, string item, string expectedDescriptionFragment) + { + var completions = await promptCallbacks.GetCompletionItemsCoreAsync(source, source.Length); + var completion = completions.SingleOrDefault(c => c.DisplayText == item); + Assert.NotNull(completion); + var description = await completion.GetExtendedDescriptionAsync(default); + Assert.Contains(expectedDescriptionFragment, description.Text); + } +}