From e35442968c066ed8163f030e8f6c634df957d30d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Feb 2026 11:47:11 +0000 Subject: [PATCH 1/2] Initial plan From 03cc73223bbe2dbb1b82af2bc2ea40b59f964bbf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Feb 2026 11:54:36 +0000 Subject: [PATCH 2/2] Pre-populate input buffer with default value to allow clearing to empty string Co-authored-by: shibayan <1356444+shibayan@users.noreply.github.com> --- Sharprompt/Forms/InputForm.cs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Sharprompt/Forms/InputForm.cs b/Sharprompt/Forms/InputForm.cs index 7798362..2c6772b 100644 --- a/Sharprompt/Forms/InputForm.cs +++ b/Sharprompt/Forms/InputForm.cs @@ -14,21 +14,23 @@ public InputForm(InputOptions options) _options = options; - _defaultValue = Optional.Create(options.DefaultValue); + var defaultText = options.DefaultValue?.ToString(); + + if (defaultText is not null) + { + foreach (var c in defaultText) + { + InputBuffer.Insert(c); + } + } } private readonly InputOptions _options; - private readonly Optional _defaultValue; protected override void InputTemplate(OffscreenBuffer offscreenBuffer) { offscreenBuffer.WritePrompt(_options.Message); - if (_defaultValue.HasValue) - { - offscreenBuffer.WriteHint($"({_defaultValue.Value}) "); - } - if (InputBuffer.Length == 0 && !string.IsNullOrEmpty(_options.Placeholder)) { offscreenBuffer.PushCursor(); @@ -56,7 +58,7 @@ protected override bool HandleEnter([NotNullWhen(true)] out T? result) { if (string.IsNullOrEmpty(input)) { - if (!TypeHelper.IsNullable && !_defaultValue.HasValue) + if (!TypeHelper.IsNullable) { SetError(Resource.Validation_Required); @@ -65,7 +67,7 @@ protected override bool HandleEnter([NotNullWhen(true)] out T? result) return false; } - result = _defaultValue; + result = default; } else {