* lisp/vc/diff-mode.el (diff-font-lock-keywords): Check for limit.

This check is necessary since 'diff-beginning-of-hunk' can move
not only backwards, but also forwards (bug#60660).
This commit is contained in:
Juri Linkov 2023-01-09 09:54:19 +02:00
parent 1f8ad353d9
commit c1401d1c6c

View file

@ -485,17 +485,19 @@ use the face `diff-removed' for removed lines, and the face
;; if below, use `diff-added'. ;; if below, use `diff-added'.
(save-match-data (save-match-data
(let ((limit (save-excursion (diff-beginning-of-hunk)))) (let ((limit (save-excursion (diff-beginning-of-hunk))))
(if (save-excursion (re-search-backward diff-context-mid-hunk-header-re limit t)) (when (< limit (point))
diff-indicator-added-face (if (save-excursion (re-search-backward diff-context-mid-hunk-header-re limit t))
diff-indicator-removed-face))))) diff-indicator-added-face
diff-indicator-removed-face))))))
(2 (if diff-use-changed-face (2 (if diff-use-changed-face
'diff-changed-unspecified 'diff-changed-unspecified
;; Otherwise, use the same method as above. ;; Otherwise, use the same method as above.
(save-match-data (save-match-data
(let ((limit (save-excursion (diff-beginning-of-hunk)))) (let ((limit (save-excursion (diff-beginning-of-hunk))))
(if (save-excursion (re-search-backward diff-context-mid-hunk-header-re limit t)) (when (< limit (point))
'diff-added (if (save-excursion (re-search-backward diff-context-mid-hunk-header-re limit t))
'diff-removed)))))) 'diff-added
'diff-removed)))))))
("^\\(?:Index\\|revno\\): \\(.+\\).*\n" ("^\\(?:Index\\|revno\\): \\(.+\\).*\n"
(0 'diff-header) (1 'diff-index prepend)) (0 'diff-header) (1 'diff-index prepend))
("^\\(?:index .*\\.\\.\\|diff \\).*\n" . 'diff-header) ("^\\(?:index .*\\.\\.\\|diff \\).*\n" . 'diff-header)