Skip to content

Commit 4350263

Browse files
authored
Enable switching from/to DiffView based on 'merge' prop status
Switch from Editor mode to DiffView based on 'merge' prop status. History, value and cleanGeneration are preserved.
1 parent da7725c commit 4350263

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/codemirror.vue

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@
8484
}
8585
}
8686
},
87+
merge(newVal) {
88+
this.$nextTick(this.switchMerge);
89+
},
8790
code(newVal, oldVal) {
8891
this.handerCodeChange(newVal, oldVal)
8992
},
@@ -179,6 +182,19 @@
179182
this.cminstance.setGutterMarker(line, 'breakpoints', info.gutterMarkers ? null : this.marker())
180183
})
181184
}
185+
},
186+
switchMerge() {
187+
// Save current values
188+
let history = this.cminstance.doc.history;
189+
let cleanGeneration = this.cminstance.doc.cleanGeneration;
190+
this.options.value = this.cminstance.getValue();
191+
192+
this.destroy();
193+
this.initialize();
194+
195+
// Restore values
196+
this.cminstance.doc.history = history;
197+
this.cminstance.doc.cleanGeneration = cleanGeneration;
182198
}
183199
},
184200
mounted() {

0 commit comments

Comments
 (0)