codediff.js
codediff.js copied to clipboard
Show context line in diffs
github shows the function that the diff you're looking at is part of, even if its declaration is many lines outside of the diffhunk:
I'm not sure how this is implemented, or if it requires language support. git diff
does this, too:
$ git diff d5ce61bccb2
diff --git a/extras/synchronizer.js b/extras/synchronizer.js
index cbe26d2..f39209b 100644
--- a/extras/synchronizer.js
+++ b/extras/synchronizer.js
@@ -200,7 +200,7 @@ function dygraphsBinarySearch(g, xVal) {
var low = 0,
high = g.numRows() - 1;
- while (low <= high) {
+ while (low < high) {
var idx = (high + low) >> 1;
var x = g.getValue(idx, 0);
if (x < xVal) {
Gerrit doesn't seem to do this. Neither does Reviewable. I don't believe Critique did, either.
(an alternative way to implement this would be to make an effort to expand the diff hunk to include the function declaration)