Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ internal static async Task<string> ReadLine(this IAnsiConsole console, Style? st
if (text.Length > 0)
{
text = text.Substring(0, text.Length - 1);
console.Write("\b \b");

if (mask != null)
{
console.Write("\b \b");
}
}

continue;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Favorite fruit?
19 changes: 19 additions & 0 deletions test/Spectre.Console.Tests/Unit/Prompts/TextPromptTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,25 @@ public Task Should_Choose_Masked_Default_Value_If_Nothing_Is_Entered_And_Prompt_
return Verifier.Verify(console.Output);
}

[Fact]
[Expectation("SecretValueBackspaceNullMask")]
public Task Should_Not_Erase_Prompt_Text_On_Backspace_If_Prompt_Is_Secret_And_Mask_Is_Null()
{
// Given
var console = new TestConsole();
console.Input.PushText("Bananas");
console.Input.PushKey(ConsoleKey.Backspace);
console.Input.PushKey(ConsoleKey.Enter);

// When
console.Prompt(
new TextPrompt<string>("Favorite fruit?")
.Secret(null));

// Then
return Verifier.Verify(console.Output);
}

[Fact]
[Expectation("SecretDefaultValueCustomMask")]
public Task Should_Choose_Custom_Masked_Default_Value_If_Nothing_Is_Entered_And_Prompt_Is_Secret_And_Mask_Is_Custom()
Expand Down