terminal: config -list to print strings inside interfaces in quotes (#2680)

Commit 3d6bbbe9 made "config -list" print strings in quotes to avoid
the strings being interpreted as terminal escape codes.  This commit
does the same for "source-list-line-color", which is a raw interface.
This fixes "config -list" with a config like

	source-list-line-color: "\x1b[34m"

The "int" variant is already printed correctly, so just use the
default case for that.
This commit is contained in:
Johannes Altmanninger
2021-09-01 18:59:15 +02:00
committed by GitHub
parent 88b163d038
commit f5105c57f7

View File

@ -82,6 +82,13 @@ func configureList(t *Term) error {
} }
switch field.Kind() { switch field.Kind() {
case reflect.Interface:
switch field := field.Interface().(type) {
case string:
fmt.Fprintf(w, "%s\t%q\n", fieldName, field)
default:
fmt.Fprintf(w, "%s\t%v\n", fieldName, field)
}
case reflect.Ptr: case reflect.Ptr:
if !field.IsNil() { if !field.IsNil() {
fmt.Fprintf(w, "%s\t%v\n", fieldName, field.Elem()) fmt.Fprintf(w, "%s\t%v\n", fieldName, field.Elem())