branch: elpa/magit
commit f8632898e83052914d8de35c0375148a8b2c99e1
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>

    magit-diff-visit--position: Don't add bogus offset when visiting index
    
    We only need to calculate the offset when visiting the worktree
    because GOTO-FILE is non-nil, despite REV not being "{worktree}".
    
    But we always added an offset when REV is "{index}".  We must only
    add an offset when visiting "{worktree}" instead of REV, including
    when REV is "{index}".  The only thing special about "{index}" is
    that `magit-diff-visit--offset' doesn't understand it, so we have
    to substitute nil, when calling that function.
---
 lisp/magit-diff.el | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el
index baa4253cc3e..900986b1a4f 100644
--- a/lisp/magit-diff.el
+++ b/lisp/magit-diff.el
@@ -1755,11 +1755,9 @@ the Magit-Status buffer for DIRECTORY."
     (let* ((line   (magit-diff-hunk-line   hunk goto-from))
            (column (magit-diff-hunk-column hunk goto-from)))
       (with-current-buffer buffer
-        (cond ((equal rev "{index}")
-               (setq line (magit-diff-visit--offset file nil line)))
-              ((equal rev "{worktree}"))
-              (goto-file
-               (setq line (magit-diff-visit--offset file rev line))))
+        (when (and goto-file (not (equal rev "{worktree}")))
+          (setq line (magit-diff-visit--offset
+                      file (if (equal rev "{index}") nil rev) line)))
         (save-restriction
           (widen)
           (goto-char (point-min))

Reply via email to