branch: externals/diff-hl
commit 82693fa09c41a2f4dc703332e024eb71825450af
Author: Prashant Vithani <[email protected]>
Commit: Prashant Vithani <[email protected]>
fix: Handle cons cell value for line-spacing
The `line-spacing` variable can be a [cons cell][1] from Emacs 31, such
as `(0.1 . 0.1)`, in addition to a plain number. Each value in this cons
is spacing above and below the line. The correct value of line-spacing
would be to use [`total-line-spacing`][1] instead of raw value.
The previous code did not handle the cons cell format, leading to a
`wrong-type-argument` error. For backward compatibility, this change
inlines the definition of `total-line-spacing` i.e. sums the above and
below spacing in case if it's cons.
[1]:
https://github.com/emacs-mirror/emacs/commit/e8f26d554b64ed63fe2b7f110d5247648b7322ed
---
diff-hl.el | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/diff-hl.el b/diff-hl.el
index 6f3f1377e6..9b628a4bab 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -315,10 +315,13 @@ It can be a relative expression as well, such as
\"HEAD^\" with Git, or
(expt text-scale-mode-step text-scale-mode-amount)
1))
(spacing (or (and (display-graphic-p) (default-value 'line-spacing))
0))
+ (total-spacing (pcase spacing
+ ((pred numberp) spacing)
+ (`(,above . ,below) (+ above below))))
(h (+ (ceiling (* (frame-char-height) scale))
- (if (floatp spacing)
- (truncate (* (frame-char-height) spacing))
- spacing)))
+ (if (floatp total-spacing)
+ (truncate (* (frame-char-height) total-spacing))
+ total-spacing)))
(w (min (frame-parameter nil (intern (format "%s-fringe"
diff-hl-side)))
diff-hl-bmp-max-width))
(_ (when (zerop w) (setq w diff-hl-bmp-max-width)))