Actually fixed the panic but reverted back to old working
All checks were successful
Build / build (push) Successful in 1m41s

This commit is contained in:
Leon Mika 2024-12-12 08:20:02 +11:00
parent 4a527cfe3d
commit a16afd0bc2

View file

@ -89,23 +89,25 @@ func (r *REPL) displayResult(ctx context.Context, w io.Writer, res any, concise
fmt.Fprintf(w, "]")
} else {
// In the off-chance that this is actually a slice of printables
vt := reflect.ValueOf(res).Type()
if tp, ok := r.typePrinters[vt]; ok {
canDisplay := true
if len(v) > 0 {
vt := reflect.SliceOf(reflect.TypeOf(v[0]))
if tp, ok := r.typePrinters[vt]; ok {
canDisplay := true
typeSlice := reflect.MakeSlice(vt, len(v), len(v))
for i := 0; i < len(v); i++ {
vv := reflect.ValueOf(v[i])
if vv.CanConvert(vt.Elem()) {
typeSlice.Index(i).Set(vv)
} else {
canDisplay = false
break
typeSlice := reflect.MakeSlice(vt, len(v), len(v))
for i := 0; i < len(v); i++ {
vv := reflect.ValueOf(v[i])
if vv.CanConvert(vt.Elem()) {
typeSlice.Index(i).Set(vv)
} else {
canDisplay = false
break
}
}
}
if canDisplay {
return tp(w, typeSlice.Interface(), concise)
if canDisplay {
return tp(w, typeSlice.Interface(), concise)
}
}
}