ui/vc-gutter: fix {next,previous}-hunk commands

They would sometimes jump to random hunks.
This commit is contained in:
Henrik Lissner 2019-09-27 15:15:30 -04:00
parent f4346cdb61
commit e079b4b1e3
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -77,7 +77,18 @@ is deferred until the file is saved. Respects `git-gutter:disabled-modes'."
(ignore (git-gutter)))))
;; update git-gutter when using magit commands
(advice-add #'magit-stage-file :after #'+vc-gutter-update-h)
(advice-add #'magit-unstage-file :after #'+vc-gutter-update-h))
(advice-add #'magit-unstage-file :after #'+vc-gutter-update-h)
(defadvice! +vc-gutter--fix-linearity-of-hunks-a (diffinfos is-reverse)
"Fixes `git-gutter:next-hunk' and `git-gutter:previous-hunk' sometimes
jumping to random hunks."
:override #'git-gutter:search-near-diff-index
(cl-position-if (let ((lineno (line-number-at-pos)))
(lambda (line)
(funcall (if is-reverse #'> #'<) lineno line)))
diffinfos
:key #'git-gutter-hunk-start-line
:from-end is-reverse)))
;; subtle diff indicators in the fringe