mirror of
https://github.com/atom/atom.git
synced 2026-02-17 10:01:25 -05:00
Swap underlying editor correctly when calling setModel on editor element
Previously, when `setModel` was called, we forgot to update the pointer to the component in the newly supplied editor. This was causing the element to not update in response to model updates but only as a result of focus or visibility changes. We suspect this regressed during the rewrite of the editor rendering layer. With this commit we will now correctly swap the element's underlying editor by updating the component pointer on the newly supplied editor. Also, if the element was already attached to another editor, we will null out the component reference on it, because one instance of `TextEditorElement` can only represent one instance of `TextEditor`.
This commit is contained in:
@@ -174,6 +174,10 @@ class TextEditorComponent {
|
||||
}
|
||||
|
||||
update (props) {
|
||||
if (props.model !== this.props.model) {
|
||||
this.props.model.component = null
|
||||
props.model.component = this
|
||||
}
|
||||
this.props = props
|
||||
this.scheduleUpdate()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user