mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
Do not append suffix to text prompt
Do not append suffix to text prompt unless there are choices or a default value specified. Closes #413
This commit is contained in:

committed by
Patrik Svensson

parent
865552c3f2
commit
2011cb2eff
@ -179,8 +179,10 @@ namespace Spectre.Console
|
||||
var builder = new StringBuilder();
|
||||
builder.Append(_prompt.TrimEnd());
|
||||
|
||||
var appendSuffix = false;
|
||||
if (ShowChoices && Choices.Count > 0)
|
||||
{
|
||||
appendSuffix = true;
|
||||
var converter = Converter ?? TypeConverterHelper.ConvertToString;
|
||||
var choices = string.Join("/", Choices.Select(choice => converter(choice)));
|
||||
builder.AppendFormat(CultureInfo.InvariantCulture, " [blue][[{0}]][/]", choices);
|
||||
@ -188,6 +190,7 @@ namespace Spectre.Console
|
||||
|
||||
if (ShowDefaultValue && DefaultValue != null)
|
||||
{
|
||||
appendSuffix = true;
|
||||
var converter = Converter ?? TypeConverterHelper.ConvertToString;
|
||||
builder.AppendFormat(
|
||||
CultureInfo.InvariantCulture,
|
||||
@ -196,8 +199,7 @@ namespace Spectre.Console
|
||||
}
|
||||
|
||||
var markup = builder.ToString().Trim();
|
||||
if (!markup.EndsWith("?", StringComparison.OrdinalIgnoreCase) &&
|
||||
!markup.EndsWith(":", StringComparison.OrdinalIgnoreCase))
|
||||
if (appendSuffix)
|
||||
{
|
||||
markup += ":";
|
||||
}
|
||||
|
Reference in New Issue
Block a user