|
1040 | 1040 |
|
1041 | 1041 | } |
1042 | 1042 | 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; |
1044 | 1047 | } |
1045 | 1048 | this.marksL.sort(cmp); |
1046 | 1049 | this.marksR.sort(cmp); |
|
1050 | 1053 | DtsScrollbarAnnotation.prototype.mark = function() { |
1051 | 1054 | if (this.annotationL && this.annotationR) { |
1052 | 1055 | //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; |
1057 | 1072 | } |
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; |
1062 | 1089 | } |
1063 | | -*/ |
1064 | 1090 | try { // the following occasionally fails |
1065 | 1091 | this.annotationL.update(this.marksL); |
1066 | 1092 | this.annotationR.update(this.marksR); |
|
1074 | 1100 | //try { // the following occasionally fails |
1075 | 1101 |
|
1076 | 1102 | try { |
1077 | | - if (this.annotationL) |
| 1103 | + if (this.annotationL !== null) |
1078 | 1104 | this.annotationL.clear(); |
1079 | 1105 | } catch (exn) { |
1080 | 1106 | console.log("annotationL: caught exception: "+exn); |
1081 | 1107 | } |
1082 | 1108 | try { |
1083 | | - if (this.annotationR) |
| 1109 | + if (this.annotationR !== null) |
1084 | 1110 | this.annotationR.clear(); |
1085 | 1111 | } catch (exn) { |
1086 | 1112 | console.log("annotationR: caught exception: "+exn); |
|
0 commit comments