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); + } +} 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]; }