From 871f0f0a5de2b30944348ad9bf708cb8611b27fe Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Fri, 20 May 2022 03:38:27 +0200 Subject: [PATCH] Make diff--font-lock-prettify do less if we don't have a left fringe * lisp/vc/diff-mode.el (diff--font-lock-prettify): Don't remove insert/deletions from the buffer if we don't have a left fringe (bug#37019). --- lisp/vc/diff-mode.el | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index 5c13c7fc389..0fd67422d55 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -2600,19 +2600,21 @@ fixed, visit it in a buffer." (defun diff--font-lock-prettify (limit) (when diff-font-lock-prettify - (save-excursion - ;; FIXME: Include the first space for context-style hunks! - (while (re-search-forward "^[-+! ]" limit t) - (unless (eq (get-text-property (match-beginning 0) 'face) 'diff-header) - (let ((spec - (alist-get - (char-before) - '((?+ . (left-fringe diff-fringe-add diff-indicator-added)) - (?- . (left-fringe diff-fringe-del diff-indicator-removed)) - (?! . (left-fringe diff-fringe-rep diff-indicator-changed)) - (?\s . (left-fringe diff-fringe-nul fringe)))))) - (put-text-property (match-beginning 0) (match-end 0) - 'display spec))))) + (when (> (frame-parameter nil 'left-fringe) 0) + (save-excursion + ;; FIXME: Include the first space for context-style hunks! + (while (re-search-forward "^[-+! ]" limit t) + (unless (eq (get-text-property (match-beginning 0) 'face) + 'diff-header) + (put-text-property + (match-beginning 0) (match-end 0) + 'display + (alist-get + (char-before) + '((?+ . (left-fringe diff-fringe-add diff-indicator-added)) + (?- . (left-fringe diff-fringe-del diff-indicator-removed)) + (?! . (left-fringe diff-fringe-rep diff-indicator-changed)) + (?\s . (left-fringe diff-fringe-nul fringe))))))))) ;; Mimicks the output of Magit's diff. ;; FIXME: This has only been tested with Git's diff output. ;; FIXME: Add support for Git's "rename from/to"? -- 2.39.2