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 <look@strawberrytea.xyz>
Link: https://orgmode.org/list/878r2xfk60.fsf@strawberrytea.xyz
This commit is contained in:
Ihor Radchenko 2024-03-05 11:02:21 +03:00
parent c2ea553be8
commit 1151c614b3
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 4 additions and 0 deletions

View File

@ -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))))