Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion CSharpRepl.Tests/CompletionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,17 @@ public async Task Complete_ReplKeywords(string source, string item)
var completion = completions.SingleOrDefault(c => c.DisplayText == item);
Assert.NotNull(completion);
}
}

[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);
}
}
9 changes: 6 additions & 3 deletions CSharpRepl/CSharpReplPromptCallbacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CompletionItem> AllItems = [Help, Exit, Clear];
}
Expand Down