Preserve leading spaces in response fields

This commit is contained in:
Matthew R. Wilson committed 2025-04-08 15:36:47 -07:00
1 parent 276144f363
commit 19c6001a38
1 file changed
+4 -2
+4 -2
View File
@@ -121,12 +121,14 @@ func ShowScreen(screen Screen, values map[string]string, crow, ccol int,
return response, err
}
// Strip leading+trailing spaces from field values
// 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.
for _, fld := range screen {
if !fld.KeepSpaces {
if _, ok := response.Values[fld.Name]; ok {
response.Values[fld.Name] =
strings.TrimSpace(response.Values[fld.Name])
strings.TrimRight(response.Values[fld.Name], " ")
}
}
}