Function: magit-diff-visit--offset
magit-diff-visit--offset is a byte-compiled function defined in
magit-diff.el.
Signature
(magit-diff-visit--offset LINE FILE &rest ARGS)
Source Code
;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-diff.el
(defun magit-diff-visit--offset (line file &rest args)
(let ((offset 0))
(with-temp-buffer
(save-excursion
(magit-with-toplevel
(cond ((stringp file)
(magit-git-insert "diff" args "--" file))
((magit-git-version< "2.50"))
((apply #'magit--diff-pair (current-buffer) file)))))
(catch 'found
(while (re-search-forward
"^@@ -\\([0-9]+\\),\\([0-9]+\\) \\+\\([0-9]+\\),\\([0-9]+\\) @@.*\n"
nil t)
(let ((from-beg (string-to-number (match-str 1)))
(from-len (string-to-number (match-str 2)))
( to-len (string-to-number (match-str 4))))
(if (<= from-beg line)
(if (< (+ from-beg from-len) line)
(cl-incf offset (- to-len from-len))
(let ((rest (- line from-beg)))
(while (> rest 0)
(pcase (char-after)
(?\s (cl-decf rest))
(?- (cl-decf offset) (cl-decf rest))
(?+ (cl-incf offset)))
(forward-line))))
(throw 'found nil))))))
(+ line offset)))