ui/vc-gutter: fix {next,previous}-hunk commands
They would sometimes jump to random hunks.
This commit is contained in:
parent
f4346cdb61
commit
e079b4b1e3
1 changed files with 12 additions and 1 deletions
|
@ -77,7 +77,18 @@ is deferred until the file is saved. Respects `git-gutter:disabled-modes'."
|
||||||
(ignore (git-gutter)))))
|
(ignore (git-gutter)))))
|
||||||
;; update git-gutter when using magit commands
|
;; update git-gutter when using magit commands
|
||||||
(advice-add #'magit-stage-file :after #'+vc-gutter-update-h)
|
(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
|
;; subtle diff indicators in the fringe
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue