ChimeHQ / Neon

A Swift library for efficient, flexible content-based text styling
BSD 3-Clause "New" or "Revised" License
324 stars 18 forks source link

Focus TextViewHighlighter on character changes #26

Closed DivineDominion closed 1 year ago

DivineDominion commented 1 year ago

NSTextStorageDelegate is informed about attribute changes, and the old setup would apply highlighting to attribute-only changes, too.

That doesn't sound too bad unless you begin to store attribute in the text storage:

https://github.com/ChimeHQ/Neon/blob/153d6e02e304eb76f3f4e58ffbec8741768e64a1/Sources/Neon/TextViewSystemInterface.swift#L72-L74

because then the highlighter loop will never stop.


Why I noticed and why I believe this is actually the correct way, stay tuned for Follow Up PR 3 :)

DivineDominion commented 1 year ago

@mattmassicotte Sorry, forgot to mention I went ahead and made executionMode injectable (required in part to test this, but then also to use it in .synchronous mode in my app)

mattmassicotte commented 1 year ago

Great change, thank you!