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

Add NSTextStorage Initializer #248

Merged
merged 3 commits into from
May 29, 2024

Conversation

thecoolwinter
Copy link
Collaborator

Description

Adds the ability to initialize the editor view using an NSTextStorage object, rather than a String binding. This allows users to use a more efficient method for storing text outside of the editor. It also means a developer who uses this API will avoid any extra string copying and can help avoid unnecessary view evaluations when using SwiftUI. That's because Bindings are compared to check if a new value was added when the value of the binding is set. Because a new value is set each keystroke, this results in the entire contents of the editor being compared character by character each keystroke.

This also adds a Text Coordinator called CombineCoordinator. This class passes on notifications to Combine streams and is a good example of a useful coordinator. This is necessary for the related issue. It could be implemented in CodeEdit but I felt it was useful as an example of a real-world coordinator and added documentation for it towards that purpose.

Additionally, I've updated the documentation for the package to reflect the current README as well as more information about coordinators.

Related Issues

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

@thecoolwinter
Copy link
Collaborator Author

@CodeEditApp/maintainers can I get a review on this

@thecoolwinter thecoolwinter merged commit 1740482 into CodeEditApp:main May 29, 2024
2 checks passed
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