ryanmcgrath / cacao

Rust bindings for AppKit (macOS) and UIKit (iOS/tvOS). Experimental, but working!
MIT License
1.84k stars 66 forks source link

AttributedString::set_text_color uses range end as a length #124

Open mndstrmr opened 1 month ago

mndstrmr commented 1 month ago

In AttributedString::set_text_color and AttributedString::set_font, range.end is used as the length field to CFRange::init, which unless I am mistaken seems wrong to me.

The documentation implies that if I set the set range 3..4 to red, I would change only character 3 to be red, not 3 through 6, which is what currently happens.

The relevant code is here: https://github.com/ryanmcgrath/cacao/blob/7ffe39891cd73984c4bea5e37d463f3398361320/src/text/attributed_string.rs#L45-L58

ryanmcgrath commented 1 month ago

which unless I am mistaken

I do not believe you are. :)

A PR is welcome, otherwise I'll get to it in the next batch of fixes once I find the time. Thanks for the callout!