codediff.js icon indicating copy to clipboard operation
codediff.js copied to clipboard

Show context line in diffs

Open danvk opened this issue 9 years ago • 2 comments

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: screen shot 2015-03-09 at 11 45 19 am

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) {

danvk avatar Mar 09 '15 15:03 danvk

Gerrit doesn't seem to do this. Neither does Reviewable. I don't believe Critique did, either.

danvk avatar Mar 09 '15 15:03 danvk

(an alternative way to implement this would be to make an effort to expand the diff hunk to include the function declaration)

danvk avatar Mar 09 '15 15:03 danvk