Subject: bug#4534: assertion failure at window.c:grow_mini_window

From: martin rudalics <[email-masked]>
Date: Thu, 24 Sep 2009 08:49:30 +0200

>> Would writing
 >>
 >>              if (height > WINDOW_TOTAL_LINES (w))
 >>                {
 >>                  freeze_window_starts (f, 1);
 >>                  grow_mini_window (w, height - WINDOW_TOTAL_LINES (w));
 >>                }
 >>
 >> instead do better?
 >
 > In my case, height < WINDOW_TOTAL_LINES (w) at that point (that's what
 > triggers the xassert), so adding the above check works exactly like
 > removing the if() altogether: it does not crash, but it does not
 > shrink the minibuffer to 5 lines, which would be the correct height.

Seems I'm too silly to understand what's going on in resize_mini_window.
Apparently

       if (EQ (Vresize_mini_windows, Qgrow_only))
         ... fails so ...
       else
         ... gets executed ...
         {
           /* Always resize to exact size needed.  */
           if (height > WINDOW_TOTAL_LINES (w))
             ... fails again, so ...
           else if (height < WINDOW_TOTAL_LINES (w))
             ... we're here ...
             {
               int old_height = WINDOW_TOTAL_LINES (w);
               freeze_window_starts (f, 0);
               shrink_mini_window (w);
               ... should resize the mini_window down to one line ...

               if (height)
                 {
                   freeze_window_starts (f, 1);
		  ... and the following causes the assertion failure to
                       trigger because the second arguments gets less
                       than zero ...
		  grow_mini_window (w, height - WINDOW_TOTAL_LINES (w));
                 }

               window_height_changed_p = WINDOW_TOTAL_LINES (w) != old_height;
             }
         }

Now if I replace the check

               if (height)

by

               if (height > WINDOW_TOTAL_LINES (w))

I should be able to avoid the delta = -1 assertion failure in
grow_mini_window.  Can you confirm my reasoning so far?

The fact that `height' is something like zero or less seems to stem from
some miscalculation (probably caused by the line-wrapping part) earlier
in the code of resize_mini_window.  If that's so could you try to find
out why height is not at least one line?

martin