1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

(diff--font-lock-prettify): Fix fringe width test

* lisp/vc/diff-mode.el (diff--font-lock-prettify):
Use 'window-fringes' instead of the 'left-fringe' frame parameter
since the former returns an integer on both GUI and TTY frames.
This commit is contained in:
john muhl 2025-08-11 17:43:20 -05:00 committed by Stefan Monnier
parent 01e351de60
commit ff05a689e3

View file

@ -1600,7 +1600,7 @@ else cover the whole buffer."
(remove-overlays nil nil 'diff-mode 'syntax)
(when font-lock-mode
(make-local-variable 'font-lock-extra-managed-props)
;; Added when diff--font-lock-prettify is non-nil!
;; Added when diff-font-lock-prettify is non-nil!
(cl-pushnew 'display font-lock-extra-managed-props)))
(defvar-local diff-mode-read-only nil
@ -2949,7 +2949,10 @@ fixed, visit it in a buffer."
(defun diff--font-lock-prettify (limit)
(when diff-font-lock-prettify
(when (> (frame-parameter nil 'left-fringe) 0)
;; FIXME: `window-fringes` uselessly allocates 4 cons cells,
;; but the previous use of `frame-paramter' ended up internally
;; calling `frame-parameters' making it even worse!
(when (> (car (window-fringes)) 0)
(save-excursion
;; FIXME: Include the first space for context-style hunks!
(while (re-search-forward "^[-+! ]" limit t)
@ -2965,7 +2968,7 @@ fixed, visit it in a buffer."
(?! . (left-fringe diff-fringe-rep diff-indicator-changed))
(?\s . (left-fringe diff-fringe-nul fringe)))))))))
;; Mimics the output of Magit's diff.
;; FIXME: This has only been tested with Git's diff output.
;; FIXME: This has been tested only with Git's diff output.
;; FIXME: Add support for Git's "rename from/to"?
(while (re-search-forward "^diff " limit t)
;; We split the regexp match into a search plus a looking-at because