3 ms·
I'm a little confused at the part about decorative attributes being done outside of the editing transaction, saying "And they are not even aware of the transact
by lilyball 3y ago
I'm a little confused at the part about decorative attributes being done outside of the editing transaction, saying "And they are not even aware of the transaction since they live in the NSLayoutManager itself, not in NSTextStorage". Decorative attributes like color do normally live in the NSTextStorage! Is the author implying that the colors applied to markdown characters are being done with NSLayoutManager's temporary attributes support (typically used to color misspelled words)? What would be the purpose of that?
- papereditor 3y agoYes. NSTextStorage can also contain the same attributes as the temporary attributes (rendering attributes in TextKit 2). The benefit of using temporary attributes is that changing them is very fast compared to invoking the full transaction on NSTextStorage. For example, switching between Light/Dark modes is very fast in Paper.
- lilyball 3y agoI would have expected a transaction to track whether any changes affect layout and avoid invalidating layout if only changing rendering attributes. I assume you've actually measured this though, and so I have to infer that this optimization does not in fact happen.
- papereditor 3y agoThings might have changed already, but yes, when I measured it there was a noticeable difference. Ideally, I would have expected it to behave like you have described.