]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/vc/diff-mode.el (diff-syntax-fontify-hunk): Add 'ignore-errors'.
authorJuri Linkov <juri@linkov.net>
Mon, 5 May 2025 16:52:28 +0000 (19:52 +0300)
committerEshel Yaron <me@eshelyaron.com>
Sat, 10 May 2025 08:49:59 +0000 (10:49 +0200)
(cherry picked from commit e5746d3677b86ef3d0ba0d7f1e916180cc4b6f69)

lisp/vc/diff-mode.el

index acdcb691ae9b63da5d144a287ad40b5403127f3e..e13825c473e3dcc4b148767340aedce9cd7133e9 100644 (file)
@@ -3143,7 +3143,12 @@ When OLD is non-nil, highlight the hunk from the old source."
               ((memq diff-font-lock-syntax '(hunk-also hunk-only))
                (with-temp-buffer
                  (insert text)
-                 (diff-syntax-fontify-props file text line-nb t))))))))
+                 ;; Enabling a major mode on a single hunk without
+                 ;; sufficient context often raises many errors such as
+                 ;; "Premature end of data", "Invalid search bound", etc.
+                 ;; So need to ignore all these errors.
+                 (ignore-errors
+                   (diff-syntax-fontify-props file text line-nb t)))))))))
 
     ;; Put properties over the hunk text
     (goto-char beg)