]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix error signaled by mouse-highlight on mode line
authorEli Zaretskii <eliz@gnu.org>
Wed, 23 Nov 2022 14:18:55 +0000 (16:18 +0200)
committerEli Zaretskii <eliz@gnu.org>
Wed, 23 Nov 2022 14:18:55 +0000 (16:18 +0200)
* src/xdisp.c (note_mode_line_or_margin_highlight): Avoid
signaling args-out-of-range errors when mode-line format uses
min-width 'display' property.  (Bug#59452)

src/xdisp.c

index b5f013ea6a18066598aed9baafddc357edeb2858..5dcf21dc4ce48c98462edd4ad731b50658ad0cd2 100644 (file)
@@ -34576,8 +34576,11 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y,
     }
 #endif /* HAVE_WINDOW_SYSTEM */
 
+  /* CHARPOS can be beyond the last position of STRING due, e.g., to
+     min-width 'display' property.  Fix that, to let all the calls to
+     get-text-property below do their thing.  */
   if (STRINGP (string))
-    pos = make_fixnum (charpos);
+    pos = make_fixnum (min (charpos, SCHARS (string) - 1));
 
   /* Set the help text and mouse pointer.  If the mouse is on a part
      of the mode line without any text (e.g. past the right edge of