Skip to content

Commit

Permalink
Only sync if values are different or future values may be lost
Browse files Browse the repository at this point in the history
Radulf321 committed Apr 23, 2018

Verified

This commit was signed with the committer’s verified signature.
vjik Sergei Predvoditelev
1 parent 63f0422 commit de309cc
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions monaco-editor.html
Original file line number Diff line number Diff line change
@@ -593,8 +593,12 @@
window.addEventListener('message', ({data}) => {
if(data.editorReference !== this.editorReference) return;
if (data.event === 'value-changed') {
this.set('_syncValue', true);
this.set('value', data.details);
// Only sync if the values are different. Otherwise the valueChanged observer won't trigger and
// the next change will be used to reset _syncValue instead of setting the desired value
if (this.value !== data.details) {
this.set('_syncValue', true);
this.set('value', data.details);
}
}
if (data.action === 'editor-focused') {
this._syncSchema();
@@ -649,8 +653,12 @@
var model = editor.getModel();
model.onDidChangeContent(() => {
if (!this._incomingValue) {
this.set('_syncValue', true);
this.set('value', model.getValue());
// Only sync if the values are different. Otherwise the valueChanged observer won't trigger and
// the next change will be used to reset _syncValue instead of setting the desired value
if (this.value !== model.getValue()) {
this.set('_syncValue', true);
this.set('value', model.getValue());
}
} else {
this.set('_incomingValue', false);
}

0 comments on commit de309cc

Please sign in to comment.