浏览代码

org-src-font-lock-fontify-block: Do not transfer non-existing properties

* lisp/org-src.el (org-src-font-lock-fontify-block): Never set
font-lock properties when `get-text-property' returns nil.  This
usually means that the property is not present in the position
property list.  The old behavior could, for example, set 'invisible
property to nil explicitly and prevent folding completely.

Fixes https://list.orgmode.org/CA+G3_PN6RvcRcvN2fM=vfK1K6UsT=nNPJ7SUucmA1Ypc=Emorg@mail.gmail.com/T/#u
Ihor Radchenko 2 年之前
父节点
当前提交
66528468a1
共有 1 个文件被更改,包括 4 次插入3 次删除
  1. 4 3
      lisp/org-src.el

+ 4 - 3
lisp/org-src.el

@@ -643,9 +643,10 @@ as `org-src-fontify-natively' is non-nil."
 	      ;; preserve, e.g., composition.
 	      ;; preserve, e.g., composition.
 	      (dolist (prop (cons 'face font-lock-extra-managed-props))
 	      (dolist (prop (cons 'face font-lock-extra-managed-props))
 		(let ((new-prop (get-text-property pos prop)))
 		(let ((new-prop (get-text-property pos prop)))
-		  (put-text-property
-		   (+ start (1- pos)) (1- (+ start next)) prop new-prop
-		   org-buffer)))
+                  (when new-prop
+		    (put-text-property
+		     (+ start (1- pos)) (1- (+ start next)) prop new-prop
+		     org-buffer))))
 	      (setq pos next)))
 	      (setq pos next)))
           (set-buffer-modified-p nil))
           (set-buffer-modified-p nil))
 	;; Add Org faces.
 	;; Add Org faces.