bug-auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#37337: [PATCH] Fix bug in `TeX-fold-hide-item' when acting on evapor


From: Florent Rougon
Subject: bug#37337: [PATCH] Fix bug in `TeX-fold-hide-item' when acting on evaporated overlays
Date: Sat, 7 Sep 2019 19:24:47 +0200

* tex-fold.el (TeX-fold-hide-item): wrap the end of the function in
(unless (equal ov-start ov-end) ...). What is done in this part isn't
useful with evaporated overlays and used to cause bugs because
`overlay-start' and `overlay-end' return nil for such overlays, and
functions such as `TeX-fold-overfull-p` try to move point to the
overlay-end. Fixes bug#37337.
---
 tex-fold.el | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/tex-fold.el b/tex-fold.el
index f66776de..76d6319a 100644
--- a/tex-fold.el
+++ b/tex-fold.el
@@ -811,23 +811,25 @@ That means, put respective properties onto overlay OV."
                           "[Error: No content found]"))))
         (display-string (if (listp computed) (car computed) computed))
         (face (when (listp computed) (cadr computed))))
-    ;; Cater for zero-length display strings.
-    (when (string= display-string "") (setq display-string TeX-fold-ellipsis))
-    ;; Add a linebreak to the display string and adjust the overlay end
-    ;; in case of an overfull line.
-    (when (TeX-fold-overfull-p ov-start ov-end display-string)
-      (setq display-string (concat display-string "\n"))
-      (move-overlay ov ov-start (save-excursion
-                                 (goto-char ov-end)
-                                 (skip-chars-forward " \t")
-                                 (point))))
-    (overlay-put ov 'mouse-face 'highlight)
-    (overlay-put ov 'display display-string)
-    (when font-lock-mode
-      (overlay-put ov 'face TeX-fold-folded-face))
-    (unless (zerop TeX-fold-help-echo-max-length)
-      (overlay-put ov 'help-echo (TeX-fold-make-help-echo
-                                 (overlay-start ov) (overlay-end ov))))))
+    ;; Do nothing if the overlay is empty
+    (unless (equal ov-start ov-end)
+      ;; Cater for zero-length display strings.
+      (when (string= display-string "") (setq display-string 
TeX-fold-ellipsis))
+      ;; Add a linebreak to the display string and adjust the overlay end
+      ;; in case of an overfull line.
+      (when (TeX-fold-overfull-p ov-start ov-end display-string)
+        (setq display-string (concat display-string "\n"))
+        (move-overlay ov ov-start (save-excursion
+                                   (goto-char ov-end)
+                                   (skip-chars-forward " \t")
+                                   (point))))
+      (overlay-put ov 'mouse-face 'highlight)
+      (overlay-put ov 'display display-string)
+      (when font-lock-mode
+        (overlay-put ov 'face TeX-fold-folded-face))
+      (unless (zerop TeX-fold-help-echo-max-length)
+        (overlay-put ov 'help-echo (TeX-fold-make-help-echo
+                                   (overlay-start ov) (overlay-end ov)))))))
 
 (defun TeX-fold-show-item (ov)
   "Show a single LaTeX macro or environment.
-- 
2.23.0






reply via email to

[Prev in Thread] Current Thread [Next in Thread]