Skip to content

Commit 295de58

Browse files
authored
Merge pull request #449 from sugiiianaaa/enhancement/add-documentation-on-suggested-repl-keywords
Show documentation on suggested REPL keywords
2 parents 2828b08 + 34563c5 commit 295de58

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

CSharpRepl.Tests/CompletionTests.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,17 @@ public async Task Complete_ReplKeywords(string source, string item)
137137
var completion = completions.SingleOrDefault(c => c.DisplayText == item);
138138
Assert.NotNull(completion);
139139
}
140-
}
140+
141+
[Theory]
142+
[InlineData("he", "help", "Show help")]
143+
[InlineData("ex", "exit", "Exit the REPL")]
144+
[InlineData("cl", "clear", "Clear the terminal")]
145+
public async Task Complete_ReplKeywords_HaveDescription(string source, string item, string expectedDescriptionFragment)
146+
{
147+
var completions = await promptCallbacks.GetCompletionItemsCoreAsync(source, source.Length);
148+
var completion = completions.SingleOrDefault(c => c.DisplayText == item);
149+
Assert.NotNull(completion);
150+
var description = await completion.GetExtendedDescriptionAsync(default);
151+
Assert.Contains(expectedDescriptionFragment, description.Text);
152+
}
153+
}

CSharpRepl/CSharpReplPromptCallbacks.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,15 +373,18 @@ private static class ReplKeywordCompletionItems
373373

374374
public static CompletionItem Help { get; } = new(
375375
ReadEvalPrintLoop.Keywords.HelpText,
376-
displayText: helpFormattedString);
376+
displayText: helpFormattedString,
377+
getExtendedDescription: _ => Task.FromResult(new FormattedString("Show help and usage information for the C# REPL.")));
377378

378379
public static CompletionItem Exit { get; } = new(
379380
ReadEvalPrintLoop.Keywords.ExitText,
380-
displayText: exitFormattedString);
381+
displayText: exitFormattedString,
382+
getExtendedDescription: _ => Task.FromResult(new FormattedString("Exit the REPL. You can also press Ctrl + d.")));
381383

382384
public static CompletionItem Clear { get; } = new(
383385
ReadEvalPrintLoop.Keywords.ClearText,
384-
displayText: clearFormattedString);
386+
displayText: clearFormattedString,
387+
getExtendedDescription: _ => Task.FromResult(new FormattedString("Clear the terminal screen.")));
385388

386389
public static IReadOnlyList<CompletionItem> AllItems = [Help, Exit, Clear];
387390
}

0 commit comments

Comments
 (0)