News for hackers. Stuff that matters.
Re:Nerdy internals of an Apple text editor by papereditor on Tuesday March 05, 2024 @04:53PM (#39609590)
Yes. 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.

Re:Nerdy internals of an Apple text editor by lilyball on Tuesday March 05, 2024 @05:06PM (#39609730)
I 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.
Re:Nerdy internals of an Apple text editor by papereditor on Tuesday March 05, 2024 @05:12PM (#39609796)
Things 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.