Fix a race condition when switching language in the code app
This commit is contained in:
parent
65ccfe39ef
commit
77dcc1c705
@ -268,11 +268,11 @@ define([
|
|||||||
////
|
////
|
||||||
|
|
||||||
framework.onContentUpdate(function (newContent) {
|
framework.onContentUpdate(function (newContent) {
|
||||||
CodeMirror.contentUpdate(newContent);
|
|
||||||
var highlightMode = newContent.highlightMode;
|
var highlightMode = newContent.highlightMode;
|
||||||
if (highlightMode && highlightMode !== CodeMirror.highlightMode) {
|
if (highlightMode && highlightMode !== CodeMirror.highlightMode) {
|
||||||
CodeMirror.setMode(highlightMode, evModeChange.fire);
|
CodeMirror.setMode(highlightMode, evModeChange.fire);
|
||||||
}
|
}
|
||||||
|
CodeMirror.contentUpdate(newContent);
|
||||||
previewPane.draw();
|
previewPane.draw();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -313,6 +313,9 @@ define([
|
|||||||
exp.contentUpdate = function (newContent) {
|
exp.contentUpdate = function (newContent) {
|
||||||
var oldDoc = canonicalize($textarea.val());
|
var oldDoc = canonicalize($textarea.val());
|
||||||
var remoteDoc = newContent.content;
|
var remoteDoc = newContent.content;
|
||||||
|
// setValueAndCursor triggers onLocal, even if we don't make any change to the content
|
||||||
|
// and it may revert other changes (metadata)
|
||||||
|
if (oldDoc === remoteDoc) { return; }
|
||||||
exp.setValueAndCursor(oldDoc, remoteDoc);
|
exp.setValueAndCursor(oldDoc, remoteDoc);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user