From 7b5603eb11a8813acc34635e6faacf8de86d7d9a Mon Sep 17 00:00:00 2001 From: "Matthew R. Wilson" Date: Sat, 12 Apr 2025 16:57:42 -0700 Subject: [PATCH] Revert the whitespace "fix" There was already a feature, Field.KeepSpaces, for the programmer to control this. The new strip-only-trailing-spaces behavior was inconsistent with the original design. --- screen.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/screen.go b/screen.go index 4beaa33..b07b828 100644 --- a/screen.go +++ b/screen.go @@ -163,14 +163,13 @@ func ShowScreenOpts(screen Screen, values map[string]string, conn net.Conn, return resp, err } - // Strip trailing spaces from field values. Most applications will - // want to strip leading spaces, too, but it's possible they want them - // preserved, so we'll leave that to the caller. + // Strip spaces from field values unless the caller requested that we + // maintain whitespace. for _, fld := range screen { if !fld.KeepSpaces { if _, ok := resp.Values[fld.Name]; ok { resp.Values[fld.Name] = - strings.TrimRight(resp.Values[fld.Name], " ") + strings.TrimSpace(resp.Values[fld.Name]) } } }