Skip to content

Commit 3d39a95

Browse files
committed
diffviewer fix: markers in scrollbars
1 parent ed12bc6 commit 3d39a95

File tree

1 file changed

+38
-12
lines changed

1 file changed

+38
-12
lines changed

diffviewer/diffviewer3.js

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,10 @@
10401040

10411041
}
10421042
var cmp = function(a, b) {
1043-
return a.from.line - b.from.line;
1043+
var x = a.from.line - b.from.line;
1044+
if (x === 0)
1045+
x = b.to.line - a.to.line;
1046+
return x;
10441047
}
10451048
this.marksL.sort(cmp);
10461049
this.marksR.sort(cmp);
@@ -1050,17 +1053,40 @@
10501053
DtsScrollbarAnnotation.prototype.mark = function() {
10511054
if (this.annotationL && this.annotationR) {
10521055
//console.log("marking...");
1053-
/*
1054-
for (var i = 0; i < this.marksL.length; i++) {
1055-
var m = this.marksL[i];
1056-
console.log('L: ['+m.from.line+'-'+m.to.line+']');
1056+
if (this.marksL.length > 0) {
1057+
var from = this.marksL[0].from.line;
1058+
var to = this.marksL[0].to.line;
1059+
var marks = [this.marksL[0]];
1060+
for (var i = 0; i < this.marksL.length; i++) {
1061+
var m = this.marksL[i];
1062+
//console.log('L: ['+m.from.line+'-'+m.to.line+']');
1063+
if (from !== undefined && to !== undefined) {
1064+
if (to < m.from.line) {
1065+
from = m.from.line;
1066+
to = m.to.line;
1067+
marks.push(m);
1068+
}
1069+
}
1070+
}
1071+
this.marksL = marks;
10571072
}
1058-
1059-
for (var i = 0; i < this.marksR.length; i++) {
1060-
var m = this.marksR[i];
1061-
console.log('R: ['+m.from.line+'-'+m.to.line+']');
1073+
if (this.marksR.length > 0) {
1074+
var from = this.marksR[0].from.line;
1075+
var to = this.marksR[0].to.line;
1076+
var marks = [this.marksR[0]];
1077+
for (var i = 0; i < this.marksR.length; i++) {
1078+
var m = this.marksR[i];
1079+
//console.log('R: ['+m.from.line+'-'+m.to.line+']');
1080+
if (from !== undefined && to !== undefined) {
1081+
if (to < m.from.line) {
1082+
from = m.from.line;
1083+
to = m.to.line;
1084+
marks.push(m);
1085+
}
1086+
}
1087+
}
1088+
this.marksR = marks;
10621089
}
1063-
*/
10641090
try { // the following occasionally fails
10651091
this.annotationL.update(this.marksL);
10661092
this.annotationR.update(this.marksR);
@@ -1074,13 +1100,13 @@
10741100
//try { // the following occasionally fails
10751101

10761102
try {
1077-
if (this.annotationL)
1103+
if (this.annotationL !== null)
10781104
this.annotationL.clear();
10791105
} catch (exn) {
10801106
console.log("annotationL: caught exception: "+exn);
10811107
}
10821108
try {
1083-
if (this.annotationR)
1109+
if (this.annotationR !== null)
10841110
this.annotationR.clear();
10851111
} catch (exn) {
10861112
console.log("annotationR: caught exception: "+exn);

0 commit comments

Comments
 (0)