org-fold-core: Fix edge case when fontification goes beyond requested
* lisp/org-fold-core.el (org-fold-core-fontify-region): Run `org-fold-core-first-unfold-functions' on all the regions unmarked by 'org-fold-core-fontified property instead of using incorrect heuristics with `point' position. Make sure that fontified region is registered as fontified according to the return value of `font-lock-default-fontify-region' Fixes https://orgmode.org/list/8735i5gd8n.fsf@gmail.com
This commit is contained in:
parent
fc6314b267
commit
9bc6c363da
|
@ -1436,7 +1436,7 @@ folded regions.")
|
|||
(defun org-fold-core-fontify-region (beg end loudly &optional force)
|
||||
"Run `font-lock-default-fontify-region' in visible regions."
|
||||
(with-silent-modifications
|
||||
(let* ((pos beg) next
|
||||
(let* ((pos beg) next font-lock-return-value
|
||||
(force (or force org-fold-core--force-fontification))
|
||||
(org-fold-core--fontifying t)
|
||||
(skip-specs
|
||||
|
@ -1467,13 +1467,22 @@ folded regions.")
|
|||
(< next end))
|
||||
(setq next (org-fold-core-next-folding-state-change nil next end))))
|
||||
(save-excursion
|
||||
(font-lock-default-fontify-region pos next loudly)
|
||||
(setq font-lock-return-value (font-lock-default-fontify-region pos next loudly))
|
||||
(save-match-data
|
||||
(unless (<= pos (point) next)
|
||||
(run-hook-with-args 'org-fold-core-first-unfold-functions pos next))))
|
||||
;; Only run within regions that are not yet touched by
|
||||
;; fontification.
|
||||
(let ((l pos) (r next) (c pos) nxt)
|
||||
(when (get-text-property c 'org-fold-core-fontified)
|
||||
(setq c (next-single-property-change c 'org-fold-core-fontified)))
|
||||
(setq nxt (next-single-property-change c 'org-fold-core-fontified nil r))
|
||||
(while (< c r)
|
||||
(run-hook-with-args 'org-fold-core-first-unfold-functions c nxt)
|
||||
(setq c (next-single-property-change nxt 'org-fold-core-fontified nil r))
|
||||
(setq nxt (next-single-property-change c 'org-fold-core-fontified nil r))))))
|
||||
(put-text-property pos next 'org-fold-core-fontified t)
|
||||
(put-text-property pos next 'fontified t)
|
||||
(setq pos next)))))
|
||||
(setq pos next))
|
||||
(or font-lock-return-value `(jit-lock-bounds ,beg . ,end)))))
|
||||
|
||||
(defun org-fold-core-update-optimisation (beg end)
|
||||
"Update huge buffer optimisation between BEG and END.
|
||||
|
|
Loading…
Reference in New Issue