From 1151c614b32b2cfb5dc62452118c4ac0ef03b1f8 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Tue, 5 Mar 2024 11:02:21 +0300 Subject: [PATCH] org-fold-core-region: Fix another edge case with newline fontification * lisp/org-fold-core.el (org-fold-core-region): Do not just update folds before/after. Refresh newlines created by splicing a fold by unfolding in the middle of an existing fold. Then, fold list between from/to will not cover the folds right before from and right after to. Reported-by: StrawberryTea Link: https://orgmode.org/list/878r2xfk60.fsf@strawberrytea.xyz --- lisp/org-fold-core.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lisp/org-fold-core.el b/lisp/org-fold-core.el index e0666c516..dda982204 100644 --- a/lisp/org-fold-core.el +++ b/lisp/org-fold-core.el @@ -1040,6 +1040,10 @@ If SPEC-OR-ALIAS is omitted and FLAG is nil, unfold everything in the region." ;; last as per Emacs defaults. This makes :extend faces span ;; past the ellipsis. See bug#65896. The face properties are ;; assigned via `org-activate-folds'. + (when (equal ?\n (char-after from)) + (font-lock-flush from (1+ from))) + (when (equal ?\n (char-after to)) + (font-lock-flush to (1+ to))) (dolist (region (org-fold-core-get-regions :from from :to to :specs spec)) (when (equal ?\n (char-after (cadr region))) (font-lock-flush (cadr region) (1+ (cadr region))))