org-latex-preview: Fix auto-gen at end of overlay

* lisp/org-latex-preview.el (org-latex-preview-auto--maybe-track-element-here):
`overlays-at' does not include overlays that end at the position it is
called on.  This caused auto-generation to not trigger immediately
when manually typing the closing delimiters of a LaTeX fragment. Fix
this by recording the position just before the end of a newly created overlay.
This commit is contained in:
Karthik Chikmagalur 2023-01-21 13:03:10 -08:00 committed by TEC
parent 1323115972
commit 3028030013
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
1 changed files with 3 additions and 1 deletions

View File

@ -679,7 +679,9 @@ If an org-latex-overlay is already present, nothing is done."
(if (<= elem-beg pos elem-end)
(progn
(overlay-put ov 'view-text t)
(set-marker org-latex-preview-auto--marker pos)
;; Record a position safely inside the created overlay
(set-marker org-latex-preview-auto--marker
(min pos (1- elem-end)))
(setq org-latex-preview-auto--from-overlay t)
nil)
(setq org-latex-preview-auto--inhibit t)