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

Changes to TextEditor.onDidChange and TextBuffer.onDidChange coming in Atom 1.23 #139

Open
maxbrunsfeld opened this issue Oct 31, 2017 · 2 comments

Comments

@maxbrunsfeld
Copy link

Hi! Thanks for maintaining the ftp-remote-edit package!

In Atom v1.23, we will some changes that may affect your package.

The methods TextEditor.onDidChange and TextBuffer.onDidChange will now call their callbacks less frequently. Previously, these callbacks would get called once for each individual change to the buffer. So if you had 5 cursors and typed a character, they would get called 5 times. Now, they will only get called once, and the event that is passed to them will contain information about all 5 of the changes that have occurred.

The same properties that have always existed on the TextBuffer.onDidChange events (oldRange, newRange, oldText, and newText) will still be there, and they will now reflect the sum of all changes that have occurred. But now there will be an additional property called changes, which will contain an array of more fine-grained objects describing the individual changes. We encourage you to use this property instead of the old ones.

Effects on this package

It looks like this package calls the changed methods in the following places:

We found these calls using a regex search, so this list might be incomplete, and it might contain some false positives.

What to do about the change

It is likely that you do not need to do anything. The old event properties will continue to work.

However, you may be able to handle changes more accurately and efficiently by using the changes field of the events rather than the old properties. The changes field does not exist in Atom 1.22 unless you use the TextBuffer.onDidChangeText method. In Atom 1.23 and above though, .onDidChange and .onDidChangeText will become identical, having both the old properties and the new changes property.

Please let me know if you have any questions. I would be happy to help!

@cschindl
Copy link
Collaborator

cschindl commented Nov 3, 2017

Hi @maxbrunsfeld,

Thanks for the information. We use the onDidChange function to replace the typed characters with * in input fields to create the impression of a password input field, because we have not found any possibility in Atom to realize password fields except with TextEditorView and this additional function. As long as the onDidChange function remains downward compatible, I don't think we need to make any changes.

@maxbrunsfeld
Copy link
Author

@cschindl The oldText and newText fields may go away at some point, and you would have to use the individual changes field in order access the old and new text. But that won't happen for many months, and we'll have a several-month period where we show deprecation warnings beforehand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants