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.
This commit is contained in:
Matthew R. Wilson committed 2025-04-12 16:57:42 -07:00
1 parent 5f2d7355e4
commit 7b5603eb11
1 file changed
+3 -4
+3 -4
View File
@@ -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])
}
}
}