mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 08:52:50 +08:00
Don't erase the prompt text when backspacing on a secret prompt with a null mask.
This commit is contained in:
parent
72704529c5
commit
bf3b91a535
@ -53,8 +53,12 @@ public static partial class AnsiConsoleExtensions
|
|||||||
if (text.Length > 0)
|
if (text.Length > 0)
|
||||||
{
|
{
|
||||||
text = text.Substring(0, text.Length - 1);
|
text = text.Substring(0, text.Length - 1);
|
||||||
|
|
||||||
|
if (mask != null)
|
||||||
|
{
|
||||||
console.Write("\b \b");
|
console.Write("\b \b");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
Favorite fruit?
|
@ -248,6 +248,25 @@ public sealed class TextPromptTests
|
|||||||
return Verifier.Verify(console.Output);
|
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]
|
[Fact]
|
||||||
[Expectation("SecretDefaultValueCustomMask")]
|
[Expectation("SecretDefaultValueCustomMask")]
|
||||||
public Task Should_Choose_Custom_Masked_Default_Value_If_Nothing_Is_Entered_And_Prompt_Is_Secret_And_Mask_Is_Custom()
|
public Task Should_Choose_Custom_Masked_Default_Value_If_Nothing_Is_Entered_And_Prompt_Is_Secret_And_Mask_Is_Custom()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user