]> code.delx.au - gnu-emacs/commitdiff
Respect fontification region calculated by major mode. Fixes bug #22316.
authorAlan Mackenzie <acm@muc.de>
Fri, 8 Jan 2016 14:41:58 +0000 (14:41 +0000)
committerAlan Mackenzie <acm@muc.de>
Fri, 8 Jan 2016 14:41:58 +0000 (14:41 +0000)
* lisp/font-lock.el (font-lock-extend-jit-lock-region-after-change): when a
fontification region has been calculated by a function on
font-lock-extend-after-change-region-function use this region rather than
changing the end position to somewhere else.

lisp/font-lock.el

index 4a92069b12effdf98de80b4a40b3fb6a433b87cf..3c1f01d58860b0b847e5d78d5a014bc69085bb3e 100644 (file)
@@ -1302,15 +1302,18 @@ This function does 2 things:
                       (point-min))))
       (when (< end (point-max))
         (setq end
-              (if (get-text-property end 'font-lock-multiline)
-                  (or (text-property-any end (point-max)
-                                         'font-lock-multiline nil)
-                      (point-max))
+              (cond
+               ((get-text-property end 'font-lock-multiline)
+                (or (text-property-any end (point-max)
+                                       'font-lock-multiline nil)
+                    (point-max)))
+               ;; If `end' has been set by the function above, don't corrupt it.
+               (font-lock-extend-after-change-region-function end)
                 ;; Rounding up to a whole number of lines should include the
                 ;; line right after `end'.  Typical case: the first char of
                 ;; the line was deleted.  Or a \n was inserted in the middle
                 ;; of a line.
-                (1+ end))))
+               (t (1+ end)))))
       ;; Finally, pre-enlarge the region to a whole number of lines, to try
       ;; and anticipate what font-lock-default-fontify-region will do, so as to
       ;; avoid double-redisplay.