1
0
mirror of synced 2025-12-16 03:18:14 +08:00

issue-69: invalidates current set of changes before editor content is replaced

This commit is contained in:
Jamie Peabody
2017-11-04 10:49:48 +00:00
parent 4e5422cf3d
commit 2bc1229fb9
2 changed files with 18 additions and 4 deletions

View File

@@ -484,9 +484,11 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
this.unbind();
},
lhs: function(text) {
this.changes = []; // invalidate existing changes
this.editor[this.id + '-lhs'].setValue(text);
},
rhs: function(text) {
this.changes = []; // invalidate existing changes
this.editor[this.id + '-rhs'].setValue(text);
},
update: function() {
@@ -796,7 +798,9 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
// set cursors
led.setCursor(Math.max(change["lhs-line-from"],0), 0); // use led.getCursor().ch ?
red.setCursor(Math.max(change["rhs-line-from"],0), 0);
led.scrollIntoView({line: change["lhs-line-to"]});
if (change["lhs-line-to"] >= 0) {
led.scrollIntoView({line: change["lhs-line-to"]});
}
},
_scrolling: function(editor_name) {
@@ -1173,6 +1177,9 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
var clazz = ['mergely', 'lhs', change['op'], 'cid-' + i];
led.addLineClass(llf, 'background', 'start');
led.addLineClass(llt, 'background', 'end');
if (change['lhs-line-from'] < 0) {
clazz.push('empty');
}
if (current_diff == i) {
if (llf != llt) {
@@ -1225,6 +1232,9 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
var clazz = ['mergely', 'rhs', change['op'], 'cid-' + i];
red.addLineClass(rlf, 'background', 'start');
red.addLineClass(rlt, 'background', 'end');
if (change['rhs-line-from'] < 0) {
clazz.push('empty');
}
if (current_diff == i) {
if (rlf != rlt) {