GNU bug report logs - #37337
2019-08-31; Error when `TeX-fold-hide-item' acts on evaporated overlays

Previous Next

Package: auctex;

Reported by: Florent Rougon <f.rougon <at> free.fr>

Date: Sat, 7 Sep 2019 21:38:01 UTC

Severity: normal

Done: Arash Esbati <arash <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 37337 <at> debbugs.gnu.org (full text, mbox):

From: Florent Rougon <f.rougon <at> free.fr>
To: 37337 <at> debbugs.gnu.org
Subject: [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





This bug report was last modified 5 years and 208 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.