Update for compatibility with Atom 1.23 #1017
Open
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.
👋 @david-driscoll, Thanks for maintaining this package!
In Atom 1.23, we'll be making a breaking change to the behavior of the
TextBuffer.onWillChange
method: an event object will no longer be passed to the method's callback. For a description of the change, see atom/text-buffer#270.The Breaking API Change
The reason that we're making this breaking change is that the
.onWillChange
method has been a source of performance problems in Atom when making many simultaneous changes to a buffer, for example when typing with many cursors. The problem is that the method used to get called once for each individual buffer change, which would result in a lot of computation per keystroke.Now, we only call the
onWillChange
callbacks once for each buffer transaction (a grouping of changes that can be undone and redone as an atomic unit). Because of this, there is no longer a singleoldRange
andnewRange
associated with the call.The Fix to Your Code
You should be able to simply use the
TextBuffer.onDidChangeText
method instead. This method calls its callback at the end of a transaction instead of the beginning, so it is able to provide information about each change that occurred.I apologize to you for not providing backwards-compatibility in this case. Because there were so few (~4) packages that use the
.onWillChange
method, we chose to just reach out to package maintainers individually, rather than trying to somehow keep old code working.