|
40 | 40 | (this.edit.state.diffViews || (this.edit.state.diffViews = [])).push(this); |
41 | 41 | this.orig = CodeMirror(pane, copyObj({value: orig, readOnly: !this.mv.options.allowEditingOriginals}, copyObj(options))); |
42 | 42 | this.orig.state.diffViews = [this]; |
| 43 | + this.classes.location = options.mergeMarkerLocation || "background"; |
43 | 44 |
|
44 | 45 | this.diff = getDiff(asString(orig), asString(options.value)); |
45 | 46 | this.chunks = getChunks(this.diff); |
|
192 | 193 | // Updating the marks for editor content |
193 | 194 |
|
194 | 195 | function clearMarks(editor, arr, classes) { |
| 196 | + function removeLineClass(l, klass) { |
| 197 | + var classList = Array.isArray(classes.location) ? classes.location : [classes.location] |
| 198 | + for (var c = 0; c < classList.length; ++c) { |
| 199 | + editor.removeLineClass(l, classList[c], klass) |
| 200 | + } |
| 201 | + } |
195 | 202 | for (var i = 0; i < arr.length; ++i) { |
196 | 203 | var mark = arr[i]; |
197 | 204 | if (mark instanceof CodeMirror.TextMarker) { |
198 | 205 | mark.clear(); |
199 | 206 | } else if (mark.parent) { |
200 | | - editor.removeLineClass(mark, "background", classes.chunk); |
201 | | - editor.removeLineClass(mark, "background", classes.start); |
202 | | - editor.removeLineClass(mark, "background", classes.end); |
| 207 | + removeLineClass(mark, classes.chunk); |
| 208 | + removeLineClass(mark, classes.start); |
| 209 | + removeLineClass(mark, classes.end); |
203 | 210 | } |
204 | 211 | } |
205 | 212 | arr.length = 0; |
|
231 | 238 | var top = Pos(from, 0), bot = editor.clipPos(Pos(to - 1)); |
232 | 239 | var cls = type == DIFF_DELETE ? classes.del : classes.insert; |
233 | 240 | function markChunk(start, end) { |
| 241 | + function addLineClass(l, klass) { |
| 242 | + var classList = Array.isArray(classes.location) ? classes.location : [classes.location] |
| 243 | + var ret = null |
| 244 | + for (var c = 0; c < classList.length; ++c) { |
| 245 | + ret = editor.addLineClass(l, classList[c], klass) |
| 246 | + } |
| 247 | + |
| 248 | + return ret |
| 249 | + } |
| 250 | + |
234 | 251 | var bfrom = Math.max(from, start), bto = Math.min(to, end); |
235 | 252 | for (var i = bfrom; i < bto; ++i) { |
236 | | - var line = editor.addLineClass(i, "background", classes.chunk); |
237 | | - if (i == start) editor.addLineClass(line, "background", classes.start); |
238 | | - if (i == end - 1) editor.addLineClass(line, "background", classes.end); |
| 253 | + var line = addLineClass(i, classes.chunk); |
| 254 | + if (i == start) addLineClass(line, classes.start); |
| 255 | + if (i == end - 1) addLineClass(line, classes.end); |
239 | 256 | marks.push(line); |
240 | 257 | } |
241 | 258 | // When the chunk is empty, make sure a horizontal line shows up |
242 | 259 | if (start == end && bfrom == end && bto == end) { |
243 | 260 | if (bfrom) |
244 | | - marks.push(editor.addLineClass(bfrom - 1, "background", classes.end)); |
| 261 | + marks.push(addLineClass(bfrom - 1, classes.end)); |
245 | 262 | else |
246 | | - marks.push(editor.addLineClass(bfrom, "background", classes.start)); |
| 263 | + marks.push(addLineClass(bfrom, classes.start)); |
247 | 264 | } |
248 | 265 | } |
249 | 266 |
|
|
0 commit comments