Skip to content

Commit

Permalink
call reflectx.Underlying on SliceElementValue directly in ListBase
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoreilly committed Nov 24, 2024
1 parent 5a6fe80 commit 6b54afe
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions core/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ func (lb *ListBase) SetSlice(sl any) *ListBase {
lb.Slice = sl
lb.sliceUnderlying = reflectx.Underlying(reflect.ValueOf(lb.Slice))
lb.isArray = reflectx.NonPointerType(reflect.TypeOf(sl)).Kind() == reflect.Array
lb.elementValue = reflectx.SliceElementValue(sl)
lb.elementValue = reflectx.Underlying(reflectx.SliceElementValue(sl))
lb.SetSliceBase()
return lb
}
Expand Down Expand Up @@ -485,8 +485,8 @@ func (lb *ListBase) BindSelect(val *int) *ListBase {

func (lb *ListBase) UpdateMaxWidths() {
lb.maxWidth = 0
npv := reflectx.NonPointerValue(lb.elementValue)
isString := npv.Type().Kind() == reflect.String && npv.Type() != reflect.TypeFor[icons.Icon]()
ev := lb.elementValue
isString := ev.Type().Kind() == reflect.String && ev.Type() != reflect.TypeFor[icons.Icon]()
if !isString || lb.SliceSize == 0 {
return
}
Expand All @@ -505,10 +505,10 @@ func (lb *ListBase) sliceElementValue(si int) reflect.Value {
if si < lb.SliceSize {
val = reflectx.Underlying(lb.sliceUnderlying.Index(si)) // deal with pointer lists
} else {
val = reflectx.Underlying(lb.elementValue)
val = lb.elementValue
}
if !val.IsValid() {
val = reflectx.Underlying(lb.elementValue)
val = lb.elementValue
}
return val
}
Expand Down

0 comments on commit 6b54afe

Please sign in to comment.