marijnh/CodeMirror — pull request #2626 by mtaran-google (2014-06-09 23:55:03+00:00)
Title: Add try/finally to endOperation

Currently, if there is an error thrown somewhere in the endOperation function it will fail to decrement delayedCallbackDepth, which makes events scheduled for firing with signalLater never get fired. This is especially bad since the delayedCallbacks list is used by all CodeMirror instances, so in our application when we had an error happen here in one CodeMirror instance, *all* the CodeMirror instances immediately stopped sending 'change' events.

The place where the try ends and the finally begins was chosen somewhat randomly here; I'd even be fine with just having the --delayedCallbackDepth part in the finally, but I didn't know if it was safe to move around.