Editors cursor are now moved to currently selected difference.

This commit is contained in:
Kljh
2014-08-17 09:14:55 +01:00
parent 4f8c91c28a
commit 3c4fe71683

View File

@@ -723,7 +723,6 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
self.current_diff++;
self.current_diff = Math.min(self.current_diff, self.changes.length-1);
self._scroll_to_change(self.changes[self.current_diff]);
self._changed(self.id + '-lhs', self.id + '-rhs');
break;
case "Up":
@@ -733,7 +732,6 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
self.current_diff--;
self.current_diff = Math.max(self.current_diff, 0);
self._scroll_to_change(self.changes[self.current_diff]);
self._changed(self.id + '-lhs', self.id + '-rhs');
break;
case "Left":
@@ -765,6 +763,10 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
var yref = led.getScrollerElement().offsetHeight * 1/2; // center between >0 and 1/2
// 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);
// using directly CodeMirror breaks canvas alignment
// var ly = led.charCoords({line: Math.max(change["lhs-line-from"],0), ch: 0}, "local").top;
@@ -1376,6 +1378,8 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
//reset
ed['lhs'].setValue(ed['lhs'].getValue());
ed['rhs'].setValue(ed['rhs'].getValue());
this._scroll_to_change(change)
},
_draw_info: function(editor_name1, editor_name2) {
var visible_page_height = jQuery(this.editor[editor_name1].getScrollerElement()).height();