Commit 867b5b67 authored by Jérome Perrin's avatar Jérome Perrin

monaco_editor: setValue once everything is initialized

parent c7d5e1b8
...@@ -124,12 +124,8 @@ ...@@ -124,12 +124,8 @@
.onStateChange(function (modification_dict) { .onStateChange(function (modification_dict) {
var queue = new RSVP.Queue(); var queue = new RSVP.Queue();
if (modification_dict.hasOwnProperty('value')) { // make the editor readonly until fully initialized
// Do not notify the UI when initializing the value this.editor.updateOptions({ readOnly: true });
this.state.ignoredChangeDuringInitialization = true;
this.editor.setValue(this.state.value);
this.state.ignoredChangeDuringInitialization = false;
}
if (modification_dict.hasOwnProperty('model_language')) { if (modification_dict.hasOwnProperty('model_language')) {
monaco.editor.setModelLanguage( monaco.editor.setModelLanguage(
this.editor.getModel(), this.editor.getModel(),
...@@ -327,10 +323,18 @@ ...@@ -327,10 +323,18 @@
enableSchemaRequest: true, enableSchemaRequest: true,
}); });
} }
}
queue.push(() => {
if (modification_dict.hasOwnProperty('value')) {
// Do not notify the UI when initializing the value
this.state.ignoredChangeDuringInitialization = true;
this.editor.setValue(this.state.value);
this.state.ignoredChangeDuringInitialization = false;
}
if (modification_dict.hasOwnProperty('editable')) { if (modification_dict.hasOwnProperty('editable')) {
this.editor.updateOptions({ readOnly: !this.state.editable }); this.editor.updateOptions({ readOnly: !this.state.editable });
} }
} })
return queue; return queue;
}) })
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment