Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focus TextViewHighlighter on character changes #26

Merged
merged 2 commits into from Nov 18, 2023

Conversation

DivineDominion
Copy link
Contributor

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:

// finally, fall back to applying color directly to the storage
assert(textStorage != nil, "TextView's NSTextStorage cannot be nil")
textStorage?.setAttributes(attrs, range: clampedRange)

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
Copy link
Contributor Author

@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
Copy link
Contributor

Great change, thank you!

@mattmassicotte mattmassicotte merged commit 4f9796e into ChimeHQ:main Nov 18, 2023
2 checks passed
@DivineDominion DivineDominion deleted the focus-character-editing branch November 18, 2023 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants