richtext: fix interactive span aliasing This commit fixes a subtle bug that only permitted a single interactive span per richtext.TextStyle. The loop iterating the spans copied the spans as a loop variable and assigned an important piece of tracking metadata only on the copy. This resulted in all interactive spans thinking they were the first, and thus the final span was the only active one. Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
1 files changed, 2 insertions(+), 1 deletions(-) M richtext/richtext.go
M richtext/richtext.go => richtext/richtext.go +2 -1
@@ 201,7 201,8 @@ func (t TextStyle) Layout(gtx layout.Context) layout.Dimensions { // OPT(dh): it'd be nice to avoid this allocation styles := make([]styledtext.SpanStyle, len(t.Styles)) numInteractive := 0 for i, st := range t.Styles { for i := range t.Styles { st := &t.Styles[i] if st.Interactive { st.interactiveIdx = numInteractive numInteractive++