Skip to content

Commit

Permalink
Bug fix: +/- hiding was too promiscuous
Browse files Browse the repository at this point in the history
  • Loading branch information
dandavison committed Apr 29, 2020
1 parent ac13c42 commit a356ede
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions magit-delta.el
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
(require 'magit)
(require 'xterm-color)

(defvar magit-delta-delta-executable "delta"
(defvar magit-delta-delta-executable "/usr/local/bin/delta"
"The delta executable on your system to be used by Magit.")

(defvar magit-delta-default-light-theme "GitHub"
Expand Down Expand Up @@ -116,9 +116,17 @@ The input buffer contents are expected to be raw git output."
(defun magit-delta-hide-plus-minus-markers ()
(save-excursion
(goto-char (point-min))
(while (re-search-forward "^\\(+\\|-\\)" nil t)
(let ((ov (make-overlay (match-beginning 0) (match-end 0))))
(overlay-put ov 'display " ")))))
;; Within hunks, hide - or + at the start of a line.
(let ((in-hunk nil))
(while (re-search-forward "^\\(diff\\|@@\\|+\\|-\\)" nil t)
(cond
((string-equal (match-string 0) "diff")
(setq in-hunk nil))
((string-equal (match-string 0) "@@")
(setq in-hunk t))
(in-hunk
(overlay-put (make-overlay (match-beginning 0) (match-end 0))
'display " ")))))))

(provide 'magit-delta)

Expand Down

0 comments on commit a356ede

Please sign in to comment.