This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Replace onDidChange with an enhanced version of onDidChangeText#273
Merged
maxbrunsfeld merged 3 commits intomasterfrom Oct 26, 2017
Merged
Replace onDidChange with an enhanced version of onDidChangeText#273maxbrunsfeld merged 3 commits intomasterfrom
maxbrunsfeld merged 3 commits intomasterfrom
Conversation
nathansobo
reviewed
Oct 26, 2017
| @emitter.on 'did-change-text', callback | ||
|
|
||
| # Public: This is now identical to {onDidChange}. | ||
| onDidChangeText: (callback) -> @onDidChange(callback) |
Contributor
There was a problem hiding this comment.
I guess it's not worth the hassle of deprecating it? Probably not.
Contributor
Author
There was a problem hiding this comment.
I think we should, but I thought we should do that in a second pass, after we remove all of our own uses of it.
Contributor
Author
There was a problem hiding this comment.
Same with oldText and newText. I want to deprecate them soon.
This was referenced Oct 26, 2017
This was referenced Oct 30, 2017
Changes to TextEditor.onDidChange and TextBuffer.onDidChange coming in Atom 1.23
nicktogo/coeditor#6
Open
Open
This was referenced Oct 31, 2017
Open
Changes to TextEditor.onDidChange and TextBuffer.onDidChange coming in Atom 1.23
tshort/atom-mdpad#2
Open
Changes to TextEditor.onDidChange and TextBuffer.onDidChange coming in Atom 1.23
pmb0/atom-perldoc#3
Open
Open
Changes to TextEditor.onDidChange and TextBuffer.onDidChange coming in Atom 1.23
t9md/atom-smalls#10
Closed
Changes to TextEditor.onDidChange and TextBuffer.onDidChange coming in Atom 1.23
abe33/atom-tablr#95
Open
Evpok
added a commit
to Evpok/latex-autocomplete
that referenced
this pull request
Nov 7, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Background
The
TextBuffer.onDidChangemethod has long been a source of performance problems because it causes its callback to be called for each individual change that happens to aTextBuffer. This behavior makes it very expensive to make a series of small changes to a buffer with any change observers. This is important for multi-cursor editing, and it also has shaped other decisions about how to mutate buffers, encouraging preprocessing strings before inserting them into text buffers rather doing the preprocessing in the buffer itself.A while ago, we added a more efficient way of observing changes to buffers -
TextBuffer.onDidChangeText. Callbacks passed to this method get called only once per transaction, and are passed an array of the consolidated changes that occurred in that transaction.Solution
This PR unifies
onDidChangeandonDidChangeText; they are now identical. Listeners get called once per transaction.I'm ensuring backwards-compatibility for existing users of
onDidChangeby synthesizing the old event propertiesoldRange,newRange,oldTextandnewText. For example, if two separate changes occur in a transaction,oldRangewill be the smallest possibleRangethat encompasses both of the changes.The
oldTextandnewTextproperties are now deprecated. Callers who are interested in the text that was inserted or removed should use thechangesproperty to examine individual changes./cc @nathansobo