]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/vc/diff-mode.el (diff-font-lock-keywords): Check for limit.
authorJuri Linkov <juri@linkov.net>
Mon, 9 Jan 2023 07:54:19 +0000 (09:54 +0200)
committerJuri Linkov <juri@linkov.net>
Mon, 9 Jan 2023 07:54:19 +0000 (09:54 +0200)
This check is necessary since 'diff-beginning-of-hunk' can move
not only backwards, but also forwards (bug#60660).

lisp/vc/diff-mode.el

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