-
-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Escape any Markup when displaying selected prompt items
If the item contained escaped markup, after the call to RemoveMarkup the string will contain unescaped markup (that the user explicitly had escaped before) for those cases we need to escape all remaining markup.
- Loading branch information
1 parent
b738187
commit ba4b7b9
Showing
3 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
test/Spectre.Console.Tests/Unit/Prompts/SelectionPromptTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using Shouldly; | ||
using Spectre.Console.Testing; | ||
using Xunit; | ||
|
||
namespace Spectre.Console.Tests.Unit | ||
{ | ||
public sealed class SelectionPromptTests | ||
{ | ||
[Fact] | ||
[GitHubIssue(608)] | ||
public void Should_Not_Throw_When_Selecting_An_Item_With_Escaped_Markup() | ||
{ | ||
// Given | ||
var console = new TestConsole(); | ||
console.Profile.Capabilities.Interactive = true; | ||
console.Input.PushKey(ConsoleKey.Enter); | ||
var input = "[red]This text will never be red[/]".EscapeMarkup(); | ||
|
||
// When | ||
var prompt = new SelectionPrompt<string>() | ||
.Title("Select one") | ||
.AddChoices(input); | ||
prompt.Show(console); | ||
|
||
// Then | ||
console.Output.ShouldContain(@"[red]This text will never be red[/]"); | ||
} | ||
} | ||
} |