|
73 | 73 | this._highlight(diff, isLightTheme() ? '#E5E833' : '#9E9E00');
|
74 | 74 | };
|
75 | 75 |
|
76 |
| - JsonInputView.prototype._highlight = function (diff, className) { |
| 76 | + JsonInputView.prototype._highlight = function (diff, color) { |
77 | 77 | var pos = getStartAndEndPosOfDiff(this.getText(), diff);
|
78 | 78 | this.codemirror.markText(pos.start, pos.end, {
|
79 |
| - css: 'background-color: ' + className |
| 79 | + css: 'background-color: ' + color |
80 | 80 | });
|
81 |
| - } |
| 81 | + }; |
82 | 82 |
|
83 | 83 | JsonInputView.prototype.clearMarkers = function () {
|
84 | 84 | this.codemirror.getAllMarks().forEach(function (marker) {
|
85 | 85 | marker.clear();
|
86 | 86 | });
|
87 |
| - } |
| 87 | + }; |
88 | 88 |
|
89 | 89 | function getStartAndEndPosOfDiff(textValue, diff) {
|
90 | 90 | var result = parse(textValue);
|
91 | 91 | var pointers = result.pointers;
|
92 |
| - var key = diff.path; |
| 92 | + var path = diff.path; |
93 | 93 | var start = {
|
94 |
| - line: pointers[key].key.line, |
95 |
| - ch: pointers[key].key.column |
| 94 | + line: pointers[path].key ? pointers[path].key.line : pointers[path].value.line, |
| 95 | + ch: pointers[path].key ? pointers[path].key.column : pointers[path].value.column |
96 | 96 | };
|
97 | 97 | var end = {
|
98 |
| - line: pointers[key].valueEnd.line, |
99 |
| - ch: pointers[key].valueEnd.column |
| 98 | + line: pointers[path].valueEnd.line, |
| 99 | + ch: pointers[path].valueEnd.column |
100 | 100 | };
|
101 | 101 |
|
102 | 102 | return {
|
|
163 | 163 | if (!leftJson || !rightJson) return;
|
164 | 164 | var diffs = jsonpatch.compare(leftJson, rightJson);
|
165 | 165 | window.diff = diffs;
|
| 166 | + |
166 | 167 | diffs.forEach(function (diff) {
|
167 | 168 | try {
|
168 | 169 | if (diff.op === 'remove') {
|
|
0 commit comments