Skip to content

Commit c2ef86d

Browse files
committed
fix(compare): sync diff editor changes back to main editors
1 parent 0f63b94 commit c2ef86d

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/js/app/CompareController.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@ export default class CompareController {
6060

6161
const originalModel = monaco.editor.createModel(leftContent, 'json');
6262
const modifiedModel = monaco.editor.createModel(rightContent, 'json');
63+
64+
originalModel.onDidChangeContent(() => {
65+
const val = originalModel.getValue();
66+
if (this.app.editors[0] && this.app.editors[0].getValue() !== val) {
67+
this.app.editors[0].setValue(val);
68+
}
69+
});
70+
71+
modifiedModel.onDidChangeContent(() => {
72+
const val = modifiedModel.getValue();
73+
if (this.app.editors[1] && this.app.editors[1].getValue() !== val) {
74+
this.app.editors[1].setValue(val);
75+
}
76+
});
77+
6378
this.diffEditor.setModel({
6479
original: originalModel,
6580
modified: modifiedModel,

0 commit comments

Comments
 (0)