1
0
mirror of synced 2025-11-06 04:30:40 +08:00

Merge branch 'Sphinxxxx-patch-1' of https://github.com/Sphinxxxx/Mergely into Sphinxxxx-Sphinxxxx-patch-1

This commit is contained in:
Jamie Peabody
2016-05-24 22:53:31 +01:00

View File

@@ -728,30 +728,35 @@ jQuery.extend(Mgly.CodeMirrorDiffView.prototype, {
sz(true);
}
this.editor[this.id + '-lhs'].on('gutterClick', function(cm, n) {
return $(this.changes).filter(function (i, change) {
if (n >= change['lhs-line-from'] && n <= change['lhs-line-to']) {
// scrollToDiff() from gutter
function gutterClicked(side, line, ev) {
// The "Merge left/right" buttons are also located in the gutter.
// Don't interfere with them:
if(ev.target && (ev.target.className === 'merge-button')) {
return;
}
// See if the user clicked the line number of a difference:
var i, change;
for (i = 0; i < this.changes.length; i++) {
change = this.changes[i];
if (line >= change[side+'-line-from'] && line <= change[side+'-line-to']) {
this._current_diff = i;
return true;
// I really don't like this here - something about gutterClick does not
// like mutating editor here. Need to trigger the scroll to diff from
// a timeout.
setTimeout(function() { this.scrollToDiff(); }.bind(this), 10);
break;
}
}.bind(this));
// I really don't like this here - something about gutterClick does not
// like mutating editor here. Need to trigger the scroll to diff from
// a timeout.
setTimeout(function() { this.scrollToDiff(); }.bind(this), 10);
}
}
this.editor[this.id + '-lhs'].on('gutterClick', function(cm, n, gutterClass, ev) {
gutterClicked.call(this, 'lhs', n, ev);
}.bind(this));
this.editor[this.id + '-rhs'].on('gutterClick', function(cm, n) {
$(this.changes).filter(function (i, change) {
if (n >= change['rhs-line-from'] && n <= change['rhs-line-to']) {
this._current_diff = i;
return true;
}
}.bind(this));
// I really don't like this here - something about gutterClick does not
// like mutating editor here. Need to trigger the scroll to diff from
// a timeout.
setTimeout(function() { this.scrollToDiff(); }.bind(this), 10);
this.editor[this.id + '-rhs'].on('gutterClick', function(cm, n, gutterClass, ev) {
gutterClicked.call(this, 'rhs', n, ev);
}.bind(this));
//bind