Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Adds the ability to initialize the editor view using an
NSTextStorage
object, rather than aString
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