fix(scroll): fixed issue where first rhs scroll was unlinked

This commit is contained in:
Jamie Peabody
2023-04-24 08:50:14 +01:00
parent df7d23244b
commit 7b2040c6ad

View File

@@ -45,6 +45,7 @@ CodeMirrorDiffView.prototype.init = function(el, options = {}) {
gutters: (this.settings.line_numbers && [ 'merge', 'CodeMirror-linenumbers' ]) || [], gutters: (this.settings.line_numbers && [ 'merge', 'CodeMirror-linenumbers' ]) || [],
}; };
this._vdoc = new VDoc({ _debug: this.settings._debug }); this._vdoc = new VDoc({ _debug: this.settings._debug });
this._linkedScrollTimeout = {};
}; };
CodeMirrorDiffView.prototype.unbind = function() { CodeMirrorDiffView.prototype.unbind = function() {
@@ -701,11 +702,14 @@ CodeMirrorDiffView.prototype._scrolling = function({ side }) {
// coming in 2s, so this will "link" scrolling the other editor to // coming in 2s, so this will "link" scrolling the other editor to
// this editor until this editor stops scrolling and times out. // this editor until this editor stops scrolling and times out.
this._skipscroll[oside] = true; this._skipscroll[oside] = true;
if (this._linkedScrollTimeout) { trace('scroll#set oside skip set:', oside, this._skipscroll);
clearTimeout(this._linkedScrollTimeout); if (this._linkedScrollTimeout[oside]) {
clearTimeout(this._linkedScrollTimeout[oside]);
trace('scroll#clearing timeout:', this._skipscroll);
} }
this._linkedScrollTimeout = setTimeout(() => { this._linkedScrollTimeout[oside] = setTimeout(() => {
this._skipscroll[oside] = false; this._skipscroll[oside] = false;
trace('scroll#set oside skip unset:', oside, this._skipscroll);
}, 100); }, 100);
const top = top_to - top_adjust; const top = top_to - top_adjust;