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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for compatibility with Atom 1.23 #4

Merged
merged 2 commits into from Oct 31, 2017
Merged

Update for compatibility with Atom 1.23 #4

merged 2 commits into from Oct 31, 2017

Conversation

maxbrunsfeld
Copy link
Contributor

馃憢 @nwhetsell, Thanks for creating 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 single oldRange and newRange 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.

The callback is still guaranteed to be called before the next frame is rendered, so in your case, the syntax highlighting should still be updated in time.

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.

for change in event.changes
# bufferRangeForScopeAtPosition is a private method of TextEditor
# (https://github.com/atom/atom/search?q=bufferRangeForScopeAtPosition+path%3Asrc+filename%3Atext-editor.coffee)
range = editor.bufferRangeForScopeAtPosition('entity.name.function.opcode.csound', event.oldRange.start)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the second argument of bufferRangeForScopeAtPosition now be change.oldRange.start instead of event.oldRange.start?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely. Thanks.

@nwhetsell nwhetsell merged commit 83663ad into nwhetsell:master Oct 31, 2017
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