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