spectre.console
spectre.console copied to clipboard
Exception when calling TextPrompt.DefaultValue(value) with brackets
Information
- OS: MacOS
- Version: 0.46.1.preview.0.8
- Terminal: iTerm
Describe the bug
TextPrompt.DefaultValue
is not escaped when displayed in TextPrompt.
To Reproduce
var queryStr = "root['config'][0]";
AnsiConsole.Prompt(new TextPrompt<string?>("Query: ").DefaultValue(queryStr).AllowEmpty());
Exception is thrown: System.InvalidOperationException: Could not find color or style ''config''.
Workaround of using Markup.Escape()
is not suitable as it retains the markup.
var result = AnsiConsole.Prompt(new TextPrompt<string?>("Query:").DefaultValue(Markup.Escape(queryStr)).AllowEmpty());
Result retains escaping: root[['config']][[0]]
A clear and concise description of what the bug is.
Expected behavior DefaultValue is escaped when displayed.
Please upvote :+1: this issue if you are interested in it.
I can confirm running into this issue as well. I have a prompt to set names for objects with the previous name as a default option so a user can just press enter for no change. If the name is set to something like "[ABC] DEF" it will except when trying to parse markup in the default value display on follow-up name changes.