terminal: config -list should print strings in quotes (#2605)

Commit 8e91d3b0b added a number of configuration options to control the
colors of sytnax highlighting, unfortunately 'config -list' will print
all of those to stdout without quoting them, resulting in the color of
the last one being applied to all subsequent text.

Change 'config -list' to print strings in quotes so that we don't
accidentally send escape sequences to the terminal.
This commit is contained in:
Alessandro Arzilli
2021-08-23 20:28:27 +02:00
committed by GitHub
parent 7cdf48605b
commit 3d6bbbe92a

View File

@ -81,13 +81,16 @@ func configureList(t *Term) error {
continue continue
} }
if field.Kind() == reflect.Ptr { switch field.Kind() {
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())
} else { } else {
fmt.Fprintf(w, "%s\t<not defined>\n", fieldName) fmt.Fprintf(w, "%s\t<not defined>\n", fieldName)
} }
} else { case reflect.String:
fmt.Fprintf(w, "%s\t%q\n", fieldName, field)
default:
fmt.Fprintf(w, "%s\t%v\n", fieldName, field) fmt.Fprintf(w, "%s\t%v\n", fieldName, field)
} }
} }