Skip to content

Commit 7e7146a

Browse files
author
Justin Martin
committed
Merge branch 'master' into gh-pages
2 parents ec22ee1 + aa8dbfe commit 7e7146a

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

js/main.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,30 +73,30 @@
7373
this._highlight(diff, isLightTheme() ? '#E5E833' : '#9E9E00');
7474
};
7575

76-
JsonInputView.prototype._highlight = function (diff, className) {
76+
JsonInputView.prototype._highlight = function (diff, color) {
7777
var pos = getStartAndEndPosOfDiff(this.getText(), diff);
7878
this.codemirror.markText(pos.start, pos.end, {
79-
css: 'background-color: ' + className
79+
css: 'background-color: ' + color
8080
});
81-
}
81+
};
8282

8383
JsonInputView.prototype.clearMarkers = function () {
8484
this.codemirror.getAllMarks().forEach(function (marker) {
8585
marker.clear();
8686
});
87-
}
87+
};
8888

8989
function getStartAndEndPosOfDiff(textValue, diff) {
9090
var result = parse(textValue);
9191
var pointers = result.pointers;
92-
var key = diff.path;
92+
var path = diff.path;
9393
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
9696
};
9797
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
100100
};
101101

102102
return {
@@ -163,6 +163,7 @@
163163
if (!leftJson || !rightJson) return;
164164
var diffs = jsonpatch.compare(leftJson, rightJson);
165165
window.diff = diffs;
166+
166167
diffs.forEach(function (diff) {
167168
try {
168169
if (diff.op === 'remove') {

0 commit comments

Comments
 (0)