]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix infloop in 'redisplay_window' when buffer is narrowed
authorEli Zaretskii <eliz@gnu.org>
Sun, 6 Feb 2022 10:26:36 +0000 (12:26 +0200)
committerEli Zaretskii <eliz@gnu.org>
Sun, 6 Feb 2022 10:26:36 +0000 (12:26 +0200)
* src/xdisp.c (redisplay_window): Ensure window-start point is in
the accessible portion of the buffer when passing it to
'window_start_acceptable_p'.  (Bug#14582)

src/xdisp.c

index db9bc512a987caece23f85e6e36ebcbd02987192..cafc50e7550a45901c6b57671d533157ae807955 100644 (file)
@@ -18754,9 +18754,8 @@ window_start_acceptable_p (Lisp_Object window, ptrdiff_t startp)
   struct text_pos ignored;
 
   /* Is STARTP in invisible text?  */
-  if (startp > BEGV
-      && ((invprop = Fget_char_property (startpos, Qinvisible, window)),
-         TEXT_PROP_MEANS_INVISIBLE (invprop) != 0))
+  if ((invprop = Fget_char_property (startpos, Qinvisible, window)),
+      TEXT_PROP_MEANS_INVISIBLE (invprop) != 0)
     return false;
 
   /* Is STARTP covered by a replacing 'display' property?  */
@@ -19285,10 +19284,12 @@ redisplay_window (Lisp_Object window, bool just_this_one_p)
   /* If current starting point was originally the beginning of a line
      but no longer is, or if the starting point is invisible but the
      buffer wants it always visible, find a new starting point.  */
-  else if ((w->start_at_line_beg
-           && !(CHARPOS (startp) <= BEGV
-                || FETCH_BYTE (BYTEPOS (startp) - 1) == '\n'))
-          || !window_start_acceptable_p (window, CHARPOS (startp)))
+  else if (w->start_at_line_beg
+          && ((CHARPOS (startp) > BEGV
+               && FETCH_BYTE (BYTEPOS (startp) - 1) != '\n')
+              || (CHARPOS (startp) >= BEGV
+                  && CHARPOS (startp) <= ZV
+                  && !window_start_acceptable_p (window, CHARPOS (startp)))))
     {
 #ifdef GLYPH_DEBUG
       debug_method_add (w, "recenter 1");