Emit events *after* update to prevent requesting update during an update

When updating synchronously in specs, we can't get away with requesting
an update before the previous update is completed. If we emit events
before the update, we have the potential for one of those events to
cause this to happen. Moving them to after is more correct anyway.
This commit is contained in:
Nathan Sobo 2014-06-20 13:29:01 -06:00
parent 68d0a99c6e
commit ef1ec9b693

View File

@ -180,18 +180,24 @@ EditorComponent = React.createClass
@scrollViewMeasurementIntervalId = null
componentWillUpdate: ->
if @props.editor.isAlive()
@props.parentView.trigger 'cursor:moved' if @cursorsMoved
@props.parentView.trigger 'selection:changed' if @selectionChanged
componentDidUpdate: (prevProps, prevState) ->
cursorsMoved = @cursorsMoved
selectionChanged = @selectionChanged
@pendingChanges.length = 0
@cursorsMoved = false
@selectionChanged = false
@refreshingScrollbars = false
@updateParentViewFocusedClassIfNeeded(prevState)
if @props.editor.isAlive()
@updateParentViewFocusedClassIfNeeded(prevState)
@props.parentView.trigger 'cursor:moved' if cursorsMoved
@props.parentView.trigger 'selection:changed' if selectionChanged
@props.parentView.trigger 'editor:display-updated'
@measureScrollbars() if @measuringScrollbars
@measureLineHeightAndCharWidthsIfNeeded(prevState)
@remeasureCharacterWidthsIfNeeded(prevState)
@props.parentView.trigger 'editor:display-updated'
requestUpdate: ->
if @performSyncUpdates ? EditorComponent.performSyncUpdates