Skip to content

Commit

Permalink
Enable switching from/to DiffView based on 'merge' prop status
Browse files Browse the repository at this point in the history
Switch from Editor mode to DiffView based on 'merge' prop status. History, value and cleanGeneration are preserved.
  • Loading branch information
MacPiaf authored Apr 17, 2018
1 parent da7725c commit 4350263
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/codemirror.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
}
}
},
merge(newVal) {
this.$nextTick(this.switchMerge);
},
code(newVal, oldVal) {
this.handerCodeChange(newVal, oldVal)
},
Expand Down Expand Up @@ -179,6 +182,19 @@
this.cminstance.setGutterMarker(line, 'breakpoints', info.gutterMarkers ? null : this.marker())
})
}
},
switchMerge() {
// Save current values
let history = this.cminstance.doc.history;
let cleanGeneration = this.cminstance.doc.cleanGeneration;
this.options.value = this.cminstance.getValue();
this.destroy();
this.initialize();
// Restore values
this.cminstance.doc.history = history;
this.cminstance.doc.cleanGeneration = cleanGeneration;
}
},
mounted() {
Expand Down

0 comments on commit 4350263

Please sign in to comment.